From 9f37a4d9a09d93acd6ac5fa5b8efd49b7470384e Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 2 Feb 2021 06:05:50 +0000 Subject: [PATCH] Rearranged order of update calls --- update.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/update.php b/update.php index 698d043a3c..d5bfc5fe39 100644 --- a/update.php +++ b/update.php @@ -717,7 +717,24 @@ function update_1396() function update_1397() { - if (!DBStructure::existsTable('thread') || !DBStructure::existsTable('user-item')) { + if (!DBA::e("INSERT INTO `post-user-notification`(`uri-id`, `uid`, `notification-type`) + SELECT `uri-id`, `uid`, `notification-type` FROM `post-user` WHERE `notification-type` != 0 + ON DUPLICATE KEY UPDATE `uri-id` = `post-user`.`uri-id`, `uid` = `post-user`.`uid`, `notification-type` = `post-user`.`notification-type`")) { + return Update::FAILED; + } + + if (!DBStructure::existsTable('user-item')) { + return Update::SUCCESS; + } + + if (!DBA::e("INSERT INTO `post-user-notification`(`uri-id`, `uid`, `notification-type`) + SELECT `uri-id`, `user-item`.`uid`, `notification-type` FROM `user-item` + INNER JOIN `item` ON `item`.`id` = `user-item`.`iid` WHERE `notification-type` != 0 + ON DUPLICATE KEY UPDATE `notification-type` = `user-item`.`notification-type`")) { + return Update::FAILED; + } + + if (!DBStructure::existsTable('thread')) { return Update::SUCCESS; } @@ -728,18 +745,5 @@ function update_1397() return Update::FAILED; } - if (!DBA::e("INSERT INTO `post-user-notification`(`uri-id`, `uid`, `notification-type`) - SELECT `uri-id`, `user-item`.`uid`, `notification-type` FROM `user-item` - INNER JOIN `item` ON `item`.`id` = `user-item`.`iid` WHERE `notification-type` != 0 - ON DUPLICATE KEY UPDATE `notification-type` = `user-item`.`notification-type`")) { - return Update::FAILED; - } - - if (!DBA::e("INSERT IGNORE INTO `post-user-notification`(`uri-id`, `uid`, `notification-type`) - SELECT `uri-id`, `uid`, `notification-type` FROM `post-user` WHERE `notification-type` != 0 - ON DUPLICATE KEY UPDATE `uri-id` = `post-user`.`uri-id`, `uid` = `post-user`.`uid`, `notification-type` = `post-user`.`notification-type`")) { - return Update::FAILED; - } - return Update::SUCCESS; }