diff options
author | Mario Vavti <mario@mariovavti.com> | 2023-04-27 22:54:45 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2023-04-27 22:54:45 +0200 |
commit | 1f81a2cb1b0974bf8fe6d0daf2c06a23f27afc98 (patch) | |
tree | cead87ce18c9b14500c59b6474c4e81b589fdcc0 /Zotlabs/Lib/Libzotdir.php | |
parent | 5da58d42f6b86d6aa026444a9163909eb5e0d49d (diff) | |
download | volse-hubzilla-1f81a2cb1b0974bf8fe6d0daf2c06a23f27afc98.tar.gz volse-hubzilla-1f81a2cb1b0974bf8fe6d0daf2c06a23f27afc98.tar.bz2 volse-hubzilla-1f81a2cb1b0974bf8fe6d0daf2c06a23f27afc98.zip |
remove updates entry if a xchan_hash mismatch is encountered
Diffstat (limited to 'Zotlabs/Lib/Libzotdir.php')
-rw-r--r-- | Zotlabs/Lib/Libzotdir.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php index 5677d2263..d9b5d7a35 100644 --- a/Zotlabs/Lib/Libzotdir.php +++ b/Zotlabs/Lib/Libzotdir.php @@ -357,6 +357,11 @@ class Libzotdir { if($zf && array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) { $xc = Libzot::import_xchan($zf['data']); + // xchan_hash mismatch - this can happen after a site re-install at the same url + if ($xc['success'] && $xc['hash'] !== $ud['ud_hash']) { + self::delete_by_hash($ud['ud_hash']); + } + // This is a workaround for a missing xchan_updated column // TODO: implement xchan_updated in the xchan table and update this column instead if($zf['data']['primary_location']['address'] && $zf['data']['primary_location']['url']) { @@ -365,6 +370,7 @@ class Libzotdir { dbesc($zf['data']['primary_location']['url']) ); } + return true; } } @@ -714,4 +720,28 @@ class Libzotdir { } + + /** + * @brief deletes a entry in updates by hash + * + * @param string $hash the channel hash + * @return boolean + */ + + static function delete_by_hash($hash) { + if (!$hash) { + return false; + } + + $x = q("DELETE FROM updates WHERE ud_hash = '%s'", + dbesc($hash) + ); + + if ($x) { + return true; + } + + return false; + } + } |