diff --git a/src/Worker/RepairDatabase.php b/src/Worker/RepairDatabase.php index 9d951dadc6..2d7526953c 100644 --- a/src/Worker/RepairDatabase.php +++ b/src/Worker/RepairDatabase.php @@ -57,9 +57,9 @@ class RepairDatabase // Add intro entries for pending contacts // We don't do this for DFRN entries since such revived contact requests seem to mostly fail. $pending_contacts = DBA::p("SELECT `uid`, `id`, `url`, `network`, `created` FROM `contact` - WHERE `pending` AND `rel` IN (?, ?) AND `network` != ? + WHERE `pending` AND `rel` IN (?, ?) AND `network` != ? AND `uid` != ? AND NOT EXISTS (SELECT `id` FROM `intro` WHERE `contact-id` = `contact`.`id`)", - 0, Contact::FOLLOWER, Protocol::DFRN); + 0, Contact::FOLLOWER, Protocol::DFRN, 0); while ($contact = DBA::fetch($pending_contacts)) { DBA::insert('intro', ['uid' => $contact['uid'], 'contact-id' => $contact['id'], 'blocked' => false, 'hash' => Strings::getRandomHex(), 'datetime' => $contact['created']]); diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 65a14536e4..8284ff8383 100755 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -671,7 +671,7 @@ return [ "comment" => "", "fields" => [ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "User id"], "fid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["fcontact" => "id"], "comment" => ""], "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id"], "comment" => ""], "knowyou" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], diff --git a/update.php b/update.php index a740019a82..f163faf02f 100644 --- a/update.php +++ b/update.php @@ -614,6 +614,10 @@ function pre_update_1364() return Update::FAILED; } + if (!DBA::e("DELETE FROM `intro` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) { + return Update::FAILED; + } + if (!DBA::e("DELETE FROM `manage` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) { return Update::FAILED; }