X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=update.php;h=d8a28173736e370706846ef7b02f3eca6eef0623;hb=edf9bdfa144795edb121d04eb0f40dfa6a73bea8;hp=94cb145c6480e20f69eff63bcac8e4fc71f21d80;hpb=fa5acb3b21e6f5c6ff40981d4c96663b34f0fad9;p=friendica.git diff --git a/update.php b/update.php index 94cb145c64..d8a2817373 100644 --- a/update.php +++ b/update.php @@ -44,12 +44,15 @@ use Friendica\Core\Addon; use Friendica\Core\Logger; use Friendica\Core\Update; use Friendica\Core\Worker; +use Friendica\Database\Database; use Friendica\Database\DBA; 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\Post; use Friendica\Model\User; use Friendica\Model\Storage; use Friendica\Util\DateTimeFormat; @@ -334,7 +337,7 @@ function update_1309() continue; } - $item = Item::selectFirst(['id', 'gravity'], ['uid' => $contact['uid'], 'guid' => $entry['guid']]); + $item = Post::selectFirst(['id', 'gravity'], ['uid' => $contact['uid'], 'guid' => $entry['guid']]); if (!DBA::isResult($item)) { continue; } @@ -429,7 +432,7 @@ function update_1332() function update_1347() { foreach (Item::ACTIVITIES as $index => $activity) { - DBA::insert('verb', ['id' => $index + 1, 'name' => $activity], true); + DBA::insert('verb', ['id' => $index + 1, 'name' => $activity], Database::INSERT_IGNORE); } return Update::SUCCESS; @@ -801,10 +804,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; } @@ -833,6 +832,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; } @@ -840,7 +851,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; } @@ -859,3 +869,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; +}