From ab0706521ecc8874f53275d470dfa57a5f457517 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 30 Jan 2015 13:45:28 -0800 Subject: let zot_refresh continue without a primary hub if one cannot be found. also weekly doc updates --- include/zot.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'include/zot.php') diff --git a/include/zot.php b/include/zot.php index f3933d030..6057bda52 100644 --- a/include/zot.php +++ b/include/zot.php @@ -298,15 +298,24 @@ function zot_refresh($them,$channel = null, $force = false) { if($channel) logger('zot_refresh: channel: ' . print_r($channel,true), LOGGER_DATA); + $url = null; + if($them['hubloc_url']) $url = $them['hubloc_url']; else { - $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d ) > 0 limit 1", - dbesc($them['xchan_hash']), - intval(HUBLOC_FLAGS_PRIMARY) + $r = q("select hubloc_url, hubloc_flags from hubloc where hubloc_hash = '%s'", + dbesc($them['xchan_hash']) ); - if($r) - $url = $r[0]['hubloc_url']; + if($r) { + foreach($r as $rr) { + if($rr['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) { + $url = $rr['hubloc_url']; + break; + } + } + if(! $url) + $url = $r[0]['hubloc_url']; + } } if(! $url) { logger('zot_refresh: no url'); -- cgit v1.2.3 From 340212d77e246e2f46f0ae1efe5199bf01a858c8 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 30 Jan 2015 15:01:10 -0800 Subject: sync_locations() toggle DB flag functions were broken - result of postgres changes. Split these into seperate set and reset blocks. --- include/zot.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'include/zot.php') diff --git a/include/zot.php b/include/zot.php index 6057bda52..04b6806c2 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1988,13 +1988,23 @@ function sync_locations($sender,$arr,$absolute = false) { } } - if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary'])) - || ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary']))) { + if(($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary'])) { $m = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d", intval(HUBLOC_FLAGS_PRIMARY), dbesc(datetime_convert()), intval($r[0]['hubloc_id']) ); + $r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY; + hubloc_change_primary($r[0]); + $what .= 'primary_hub '; + $changed = true; + } + elseif((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary'])) { + $m = q("update hubloc set hubloc_flags = (hubloc_flags | %d), hubloc_updated = '%s' where hubloc_id = %d", + intval(HUBLOC_FLAGS_PRIMARY), + dbesc(datetime_convert()), + intval($r[0]['hubloc_id']) + ); // make sure hubloc_change_primary() has current data $r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY; hubloc_change_primary($r[0]); @@ -2009,8 +2019,7 @@ function sync_locations($sender,$arr,$absolute = false) { $changed = true; } } - if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) && (! $location['deleted'])) - || ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && ($location['deleted']))) { + if(($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) && (! $location['deleted'])) { $n = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d", intval(HUBLOC_FLAGS_DELETED), dbesc(datetime_convert()), @@ -2019,6 +2028,15 @@ function sync_locations($sender,$arr,$absolute = false) { $what .= 'delete_hub '; $changed = true; } + elseif((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && ($location['deleted'])) { + $n = q("update hubloc set hubloc_flags = (hubloc_flags | %d), hubloc_updated = '%s' where hubloc_id = %d", + intval(HUBLOC_FLAGS_DELETED), + dbesc(datetime_convert()), + intval($r[0]['hubloc_id']) + ); + $what .= 'delete_hub '; + $changed = true; + } continue; } -- cgit v1.2.3