aboutsummaryrefslogtreecommitdiffstats
path: root/include/hubloc.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/hubloc.php')
-rw-r--r--include/hubloc.php30
1 files changed, 13 insertions, 17 deletions
diff --git a/include/hubloc.php b/include/hubloc.php
index 7af4e471b..2cce7a725 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -175,40 +175,36 @@ function remove_obsolete_hublocs() {
/**
* @brief Remove duplicate singleton hublocs
*
+ * This should not actually happen but it appears it does - probably due to race conditions.
* This function will just leave the hubloc with the highest id (latest)
*
+ * TODO: we should probably do something about that at the DB level.
+ *
*/
function remove_duplicate_singleton_hublocs() {
- $hublocs = dbq("SELECT
- hubloc_id_url,
- COUNT(hubloc_id_url)
- FROM
- hubloc
- WHERE
- hubloc_network IN (
+ $hublocs = dbq("SELECT hubloc_hash, COUNT(hubloc_hash) FROM hubloc WHERE
+ hubloc_network IN(
'activitypub',
'diaspora',
'friendica-over-diaspora',
'gnusoc'
)
- GROUP BY
- hubloc_id_url
- HAVING
- COUNT(hubloc_id_url) > 1"
+ GROUP BY hubloc_hash
+ HAVING COUNT(hubloc_hash) > 1"
);
foreach($hublocs as $hubloc) {
- $hubloc_id_url = $hubloc['hubloc_id_url'];
+ $hubloc_hash = $hubloc['hubloc_hash'];
- $max_id = q("select max(hubloc_id) as max_id from hubloc where hubloc_id_url = '%s'",
- dbesc($hubloc_id_url)
+ $max_id = q("select max(hubloc_id) as max_id from hubloc where hubloc_hash = '%s'",
+ dbesc($hubloc_hash)
);
$id = $max_id[0]['max_id'];
- if($hubloc_id_url && $id) {
- q("delete from hubloc where hubloc_id_url = '%s' and hubloc_id != %d",
- dbesc($hubloc_id_url),
+ if($hubloc_hash && $id) {
+ q("delete from hubloc where hubloc_hash = '%s' and hubloc_id != %d",
+ dbesc($hubloc_hash),
intval($id)
);
}