aboutsummaryrefslogtreecommitdiffstats
path: root/include/zot.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-04-06 16:24:19 -0700
committerMario Vavti <mario@mariovavti.com>2017-04-07 11:08:26 +0200
commite6139c9f4950173e416b6bfabaceb2e1e813cedf (patch)
treeafa3db1e517f12a84f7bd95e3c1ec58719a705f8 /include/zot.php
parentb347e1d86148940bc164c4859d3e77ee6f2fb113 (diff)
downloadvolse-hubzilla-e6139c9f4950173e416b6bfabaceb2e1e813cedf.tar.gz
volse-hubzilla-e6139c9f4950173e416b6bfabaceb2e1e813cedf.tar.bz2
volse-hubzilla-e6139c9f4950173e416b6bfabaceb2e1e813cedf.zip
revisit the import_author_zot algorithm yet again. There was one bug that we weren't returning necessary information in the first SQL query - and performance/loading problem if one tries to refresh a dead site.
Diffstat (limited to 'include/zot.php')
-rw-r--r--include/zot.php36
1 files changed, 34 insertions, 2 deletions
diff --git a/include/zot.php b/include/zot.php
index 8afed1c3c..d1fd1db6a 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3585,7 +3585,9 @@ function import_author_zot($x) {
// of a hassle to repair. If either or both are missing, do a full discovery probe.
$hash = make_xchan_hash($x['guid'],$x['guid_sig']);
- $r1 = q("select hubloc_url from hubloc where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and hubloc_primary = 1 limit 1",
+
+ $r1 = q("select hubloc_url, hubloc_updated, site_dead from hubloc left join site on
+ hubloc_url = site_url where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and hubloc_primary = 1 limit 1",
dbesc($x['guid']),
dbesc($x['guid_sig'])
);
@@ -3595,12 +3597,42 @@ function import_author_zot($x) {
dbesc($x['guid_sig'])
);
+ $site_dead = false;
+
+ if($r1 && intval($r1[0]['site_dead'])) {
+ $site_dead = true;
+ }
+
+ // We have valid and somewhat fresh information.
+
if($r1 && $r2 && $r1[0]['hubloc_updated'] > datetime_convert('UTC','UTC','now - 1 week')) {
logger('in cache', LOGGER_DEBUG);
return $hash;
}
- logger('not in cache - probing: ' . print_r($x,true), LOGGER_DEBUG);
+ logger('not in cache or cache stale - probing: ' . print_r($x,true), LOGGER_DEBUG,LOG_INFO);
+
+ // The primary hub may be dead. Try to find another one associated with this identity that is
+ // still alive. If we find one, use that url for the discovery/refresh probe. Otherwise, the dead site
+ // is all we have and there is no point probing it. Just return the hash indicating we have a
+ // cached entry and the identity is valid. It's just unreachable until they bring back their
+ // server from the grave or create another clone elsewhere.
+
+ if($site_dead) {
+ logger('dead site - ignoring', LOGGER_DEBUG,LOG_INFO);
+
+ $r = q("select hubloc_url from hubloc left join site on hubloc_url = site_url
+ where hubloc_hash = '%s' and site_dead = 0",
+ dbesc($hash)
+ );
+ if($r) {
+ logger('found another site that is not dead: ' . $r[0]['hubloc_url'], LOGGER_DEBUG,LOG_INFO);
+ $x['url'] = $r[0]['hubloc_url'];
+ }
+ else {
+ return $hash;
+ }
+ }
$them = array('hubloc_url' => $x['url'], 'xchan_guid' => $x['guid'], 'xchan_guid_sig' => $x['guid_sig']);
if(zot_refresh($them))