X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=update.php;h=b5d17848941bfa18994dc445454c910a72f2c799;hb=4cc52cef6b84e02687be5e306ef333060dcc8f53;hp=c3c83b937b9116609e20dbb16761760fff3a5e00;hpb=1acc5ffb38cbd0b109f0c36f6c87eb41c8b38c5f;p=friendica.git diff --git a/update.php b/update.php index c3c83b937b..b5d1784894 100644 --- a/update.php +++ b/update.php @@ -50,6 +50,7 @@ use Friendica\Database\DBStructure; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Item; +use Friendica\Model\Notify; use Friendica\Model\Photo; use Friendica\Model\User; use Friendica\Model\Storage; @@ -802,10 +803,6 @@ function pre_update_1377() { DBStructure::checkInitialValues(); - if (!DBA::e("DELETE FROM `item` WHERE NOT `parent` IN (SELECT `id` FROM `item`)")) { - return Update::FAILED; - } - if (!DBA::e("DELETE FROM `item` WHERE NOT `author-id` IN (SELECT `id` FROM `contact`)")) { return Update::FAILED; } @@ -834,6 +831,18 @@ function pre_update_1377() return Update::FAILED; } + if (DBStructure::existsTable('diaspora-interaction') && !DBA::e("DELETE FROM `diaspora-interaction` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { + return Update::FAILED; + } + + if (DBStructure::existsTable('item-activity') && !DBA::e("DELETE FROM `item-activity` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { + return Update::FAILED; + } + + if (DBStructure::existsTable('item-content') && !DBA::e("DELETE FROM `item-content` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { + return Update::FAILED; + } + if (!DBA::e("DELETE FROM `notify` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { return Update::FAILED; } @@ -841,7 +850,6 @@ function pre_update_1377() if (!DBA::e("UPDATE `notify` SET `parent-uri-id` = NULL WHERE `parent-uri-id` = 0")) { return Update::FAILED; } - if (!DBA::e("DELETE FROM `notify` WHERE `parent-uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) { return Update::FAILED; } @@ -860,3 +868,18 @@ function pre_update_1377() return Update::SUCCESS; } + +function update_1380() +{ + if (!DBA::e("UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`iid` SET `notify`.`uri-id` = `item`.`uri-id` WHERE `notify`.`uri-id` IS NULL AND `notify`.`otype` IN (?, ?)", + Notify\ObjectType::ITEM, Notify\ObjectType::PERSON)) { + return Update::FAILED; + } + + if (!DBA::e("UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`parent` SET `notify`.`parent-uri-id` = `item`.`uri-id` WHERE `notify`.`parent-uri-id` IS NULL AND `notify`.`otype` IN (?, ?)", + Notify\ObjectType::ITEM, Notify\ObjectType::PERSON)) { + return Update::FAILED; + } + + return Update::SUCCESS; +}