aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-04-08 12:20:44 +0000
committerMario <mario@mariovavti.com>2020-04-08 12:20:44 +0000
commit9c2d48bcd4b8c5cb4efea1232ef3e52c1a0649c9 (patch)
tree84084e70aea409aa494f5d39e7c219dae3eaa038
parentd8802e4fc8c779f18dd9ff6d15a8e507c89fa642 (diff)
downloadvolse-hubzilla-9c2d48bcd4b8c5cb4efea1232ef3e52c1a0649c9.tar.gz
volse-hubzilla-9c2d48bcd4b8c5cb4efea1232ef3e52c1a0649c9.tar.bz2
volse-hubzilla-9c2d48bcd4b8c5cb4efea1232ef3e52c1a0649c9.zip
update 1236: we have seen situations in the wild where a zot6 xchan was present while its hubloc was missing. fix those separately if required so that we cover both situations.
-rw-r--r--Zotlabs/Update/_1236.php46
1 files changed, 33 insertions, 13 deletions
diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php
index 6b4e7b299..e57338e16 100644
--- a/Zotlabs/Update/_1236.php
+++ b/Zotlabs/Update/_1236.php
@@ -61,6 +61,34 @@ class _1236 {
xchan_store_lowlevel($rec);
}
+ // Now try again
+ $xchan = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'",
+ dbesc($guid)
+ );
+
+ if(! $xchan) {
+ logger('Could not create zot6 xchan record for: ' . $zot_xchan);
+ continue;
+ }
+
+ }
+
+ $zot6_xchan = $xchan[0]['xchan_hash'];
+ $zot6_xchan_guid_sig = $xchan[0]['xchan_guid_sig'];
+
+ $hubloc = q("SELECT hubloc_hash FROM hubloc WHERE hubloc_guid = '%s' AND hubloc_url = '%s' AND hubloc_network = 'zot6'",
+ dbesc($guid),
+ dbesc(z_root())
+ );
+
+ if(! $hubloc) {
+ // This should not actually happen.
+ // A local zot6 hubloc for every channel should have been
+ // created in update _1226.
+
+ // In case this failed, we will try to fix it here.
+ logger('No local zot6 hubloc found for: ' . $rr['channel_hash']);
+
$h = q("SELECT * FROM hubloc WHERE hubloc_hash = '%s' AND hubloc_url = '%s' LIMIT 1",
dbesc($zot_xchan),
dbesc(z_root())
@@ -68,31 +96,23 @@ class _1236 {
if($h) {
$rec = $h[0];
- $rec['hubloc_hash'] = $zhash;
+ $rec['hubloc_hash'] = $zot6_xchan;
$rec['hubloc_guid_sig'] = 'sha256.' . $rec['hubloc_guid_sig'];
$rec['hubloc_network'] = 'zot6';
$rec['hubloc_url_sig'] = 'sha256.' . $rec['hubloc_url_sig'];
$rec['hubloc_callback'] = z_root() . '/zot';
$rec['hubloc_id_url'] = channel_url($rr);
$rec['hubloc_site_id'] = Libzot::make_xchan_hash(z_root(),get_config('system','pubkey'));
- hubloc_store_lowlevel($rec);
- }
- // Now try again
- $xchan = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'",
- dbesc($guid)
- );
+ $hubloc = hubloc_store_lowlevel($rec);
+ }
- if(!$xchan) {
- logger('Could not create zot6 xchan record for: ' . $zot_xchan);
+ if(! $hubloc) {
+ logger('Could not create local zot6 hubloc record for: ' . $zot_xchan);
continue;
}
-
}
- $zot6_xchan = $xchan[0]['xchan_hash'];
- $zot6_xchan_guid_sig = $xchan[0]['xchan_guid_sig'];
-
logger('Transforming channel: ' . $zot_xchan);
q("UPDATE channel SET channel_hash = '%s', channel_portable_id = '%s', channel_guid_sig = '%s' WHERE channel_hash = '%s'",
dbesc($zot6_xchan),