aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Fhubloc_id_url.php33
-rw-r--r--Zotlabs/Update/_1238.php24
2 files changed, 39 insertions, 18 deletions
diff --git a/Zotlabs/Module/Fhubloc_id_url.php b/Zotlabs/Module/Fhubloc_id_url.php
index 3d27df4fa..a5627a33d 100644
--- a/Zotlabs/Module/Fhubloc_id_url.php
+++ b/Zotlabs/Module/Fhubloc_id_url.php
@@ -10,11 +10,16 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller {
if(! is_site_admin())
return;
- // completely remove broken xchan entries
- $r = dbq("DELETE FROM xchan WHERE xchan_hash = ''");
+ q("START TRANSACTION");
+
+ // remove broken xchan entries
+ $r0 = dbq("DELETE FROM xchan WHERE xchan_hash = ''");
+
+ // remove broken hubloc entries
+ $r1 = dbq("DELETE FROM hubloc WHERE hubloc_hash = ''");
// fix legacy zot hubloc_id_url
- $r1 = dbq("UPDATE hubloc
+ $r2 = dbq("UPDATE hubloc
SET hubloc_id_url = CONCAT(hubloc_url, '/channel/', SUBSTRING(hubloc_addr FROM 1 FOR POSITION('@' IN hubloc_addr) -1))
WHERE hubloc_network = 'zot'
AND hubloc_id_url = ''"
@@ -23,13 +28,13 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller {
// fix singleton networks hubloc_id_url
if(ACTIVE_DBTYPE == DBTYPE_MYSQL) {
// fix entries for activitypub which miss the xchan_url due to an earlier bug
- $r2 = dbq("UPDATE xchan
+ $r3 = dbq("UPDATE xchan
SET xchan_url = xchan_hash
WHERE xchan_network = 'activitypub'
AND xchan_url = ''"
);
- $r3 = dbq("UPDATE hubloc
+ $r4 = dbq("UPDATE hubloc
LEFT JOIN xchan ON hubloc.hubloc_hash = xchan.xchan_hash
SET hubloc.hubloc_id_url = xchan.xchan_url
WHERE hubloc.hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc')
@@ -40,13 +45,13 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller {
}
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
// fix entries for activitypub which miss the xchan_url due to an earlier bug
- $r2 = dbq("UPDATE xchan
+ $r3 = dbq("UPDATE xchan
SET xchan_url = xchan_hash
WHERE xchan_network = 'activitypub'
AND xchan_url = ''"
);
- $r3 = dbq("UPDATE hubloc
+ $r4 = dbq("UPDATE hubloc
SET hubloc_id_url = xchan_url
FROM xchan
WHERE hubloc_hash = xchan_hash
@@ -58,9 +63,17 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller {
}
- if($r && $r1 && $r2 && $r3)
+ if($r0 && $r1 && $r2 && $r3 && $r4) {
+ // remove hubloc entries where hubloc_id_url could not be fixed
+ $r5 = dbq("DELETE FROM hubloc WHERE hubloc_id_url = ''");
+ }
+
+ if($r0 && $r1 && $r2 && $r3 && $r4 && $r5) {
+ q("COMMIT");
return 'Completed';
- else
- return 'Failed';
+ }
+
+ q("ROLLBACK");
+ return 'Failed';
}
}
diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php
index 364763ee4..1c79cc36e 100644
--- a/Zotlabs/Update/_1238.php
+++ b/Zotlabs/Update/_1238.php
@@ -12,11 +12,14 @@ class _1238 {
dbesc('Premium Channel')
);
- // completely remove broken xchan entries
- $r = dbq("DELETE FROM xchan WHERE xchan_hash = ''");
+ // remove broken xchan entries
+ $r0 = dbq("DELETE FROM xchan WHERE xchan_hash = ''");
+
+ // remove broken hubloc entries
+ $r1 = dbq("DELETE FROM hubloc WHERE hubloc_hash = ''");
// fix legacy zot hubloc_id_url
- $r1 = dbq("UPDATE hubloc
+ $r2 = dbq("UPDATE hubloc
SET hubloc_id_url = CONCAT(hubloc_url, '/channel/', SUBSTRING(hubloc_addr FROM 1 FOR POSITION('@' IN hubloc_addr) -1))
WHERE hubloc_network = 'zot'
AND hubloc_id_url = ''"
@@ -25,13 +28,13 @@ class _1238 {
// fix singleton networks hubloc_id_url
if(ACTIVE_DBTYPE == DBTYPE_MYSQL) {
// fix entries for activitypub which miss the xchan_url due to an earlier bug
- $r2 = dbq("UPDATE xchan
+ $r3 = dbq("UPDATE xchan
SET xchan_url = xchan_hash
WHERE xchan_network = 'activitypub'
AND xchan_url = ''"
);
- $r3 = dbq("UPDATE hubloc
+ $r4 = dbq("UPDATE hubloc
LEFT JOIN xchan ON hubloc.hubloc_hash = xchan.xchan_hash
SET hubloc.hubloc_id_url = xchan.xchan_url
WHERE hubloc.hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc')
@@ -41,13 +44,13 @@ class _1238 {
}
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
// fix entries for activitypub which miss the xchan_url due to an earlier bug
- $r2 = dbq("UPDATE xchan
+ $r3 = dbq("UPDATE xchan
SET xchan_url = xchan_hash
WHERE xchan_network = 'activitypub'
AND xchan_url = ''"
);
- $r3 = dbq("UPDATE hubloc
+ $r4 = dbq("UPDATE hubloc
SET hubloc_id_url = xchan_url
FROM xchan
WHERE hubloc_hash = xchan_hash
@@ -57,7 +60,12 @@ class _1238 {
);
}
- if($r1 && $r2 && $r3) {
+ if($r0 && $r1 && $r2 && $r3 && $r4) {
+ // remove hubloc entries where hubloc_id_url could not be fixed
+ $r5 = dbq("DELETE FROM hubloc WHERE hubloc_id_url = ''");
+ }
+
+ if($r0 && $r1 && $r2 && $r3 && $r4 && $r5) {
q("COMMIT");
return UPDATE_SUCCESS;
}