From 675343f575f7f53f85462e8604ea7e81e05ad51f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 30 Oct 2018 17:18:15 -0700 Subject: issue syncing the channel_primary setting which shows up as a wrong count on the admin summary page --- include/hubloc.php | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'include/hubloc.php') diff --git a/include/hubloc.php b/include/hubloc.php index d1170a62c..2efafc29b 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -186,31 +186,30 @@ function hubloc_change_primary($hubloc) { logger('no hubloc'); return false; } - if(! (intval($hubloc['hubloc_primary']))) { - logger('not primary: ' . $hubloc['hubloc_url']); - return false; - } - logger('setting primary: ' . $hubloc['hubloc_url']); + logger('setting primary: ' . $hubloc['hubloc_url'] . ((intval($hubloc['hubloc_primary'])) ' true' : 'false')); - // See if there's a local channel + // See if this is a local hubloc and if so update the primary for the corresponding channel record. - $r = q("select channel_id, channel_primary from channel where channel_hash = '%s' limit 1", - dbesc($hubloc['hubloc_hash']) - ); - if($r) { - if(! $r[0]['channel_primary']) { - q("update channel set channel_primary = 1 where channel_id = %d", - intval($r[0]['channel_id']) - ); - } - else { - q("update channel set channel_primary = 0 where channel_id = %d", + if($hubloc['hubloc_url'] === z_root()) { + $r = q("select channel_id from channel where channel_hash = '%s' limit 1", + dbesc($hubloc['hubloc_hash']) + ); + if($r) { + q("update channel set channel_primary = %d where channel_id = %d", + intval($hubloc['hubloc_primary']), intval($r[0]['channel_id']) ); } } + // we only need to proceed further if this particular hubloc is now primary + + if(! (intval($hubloc['hubloc_primary']))) { + logger('not primary: ' . $hubloc['hubloc_url']); + return false; + } + // do we even have an xchan for this hubloc and if so is it already set as primary? $r = q("select * from xchan where xchan_hash = '%s' limit 1", -- cgit v1.2.3 From 9594105e577fc7d436273f32d2e067c5c277ae52 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 30 Oct 2018 17:21:39 -0700 Subject: typo --- include/hubloc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/hubloc.php') diff --git a/include/hubloc.php b/include/hubloc.php index 2efafc29b..b2903b0ee 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -187,7 +187,7 @@ function hubloc_change_primary($hubloc) { return false; } - logger('setting primary: ' . $hubloc['hubloc_url'] . ((intval($hubloc['hubloc_primary'])) ' true' : 'false')); + logger('setting primary: ' . $hubloc['hubloc_url'] . ((intval($hubloc['hubloc_primary'])) ? ' true' : ' false')); // See if this is a local hubloc and if so update the primary for the corresponding channel record. -- cgit v1.2.3