]> git.mxchange.org Git - friendica.git/blobdiff - update.php
Merge pull request #10229 from MrPetovan/bug/fatal-errors
[friendica.git] / update.php
index a59f0ca1352311333df863140fa207aa56b93ad8..819085f7ff2f5c6f1342d4f36c3a9e851997b039 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -799,6 +799,14 @@ function update_1400()
                return Update::FAILED;
        }
 
+       if (!DBA::e("INSERT IGNORE INTO `post-thread-user` (`uri-id`, `owner-id`, `author-id`, `causer-id`, `network`,
+               `created`, `received`, `changed`, `commented`, `uid`,  `wall`, `contact-id`, `unseen`, `hidden`, `origin`, `psid`, `post-user-id`)
+               SELECT `uri-id`, `owner-id`, `author-id`, `causer-id`, `network`, `created`, `received`, `received`, `received`,
+                       `uid`, `wall`, `contact-id`, `unseen`, `hidden`, `origin`, `psid`, `id`
+               FROM `post-user` WHERE `gravity` = 0 AND NOT EXISTS(SELECT `uri-id` FROM `post-thread-user` WHERE `post-user-id` = `post-user`.id)")) {
+               return Update::FAILED;
+       }
+
        if (!DBA::e("UPDATE `post-thread-user` INNER JOIN `post-thread` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
                SET `post-thread-user`.`owner-id` = `post-thread`.`owner-id`, `post-thread-user`.`author-id` = `post-thread`.`author-id`,
                `post-thread-user`.`causer-id` = `post-thread`.`causer-id`, `post-thread-user`.`network` = `post-thread`.`network`,
@@ -809,3 +817,98 @@ function update_1400()
 
        return Update::SUCCESS;
 }
+
+function pre_update_1403()
+{
+       // Necessary before a primary key change
+       if (!DBA::e("DROP TABLE `parsed_url`")) {
+               return Update::FAILED;
+       }
+
+       return Update::SUCCESS;
+}
+
+function update_1404()
+{
+       $tasks = DBA::select('workerqueue', ['id', 'command', 'parameter'], ['command' => ['notifier', 'delivery', 'apdelivery', 'done' => false]]);
+       while ($task = DBA::fetch($tasks)) {
+               $parameters = json_decode($task['parameter'], true);
+       
+               if (in_array($parameters[0], [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
+                       continue;
+               }
+       
+               switch (strtolower($task['command'])) {
+                       case 'notifier':
+                               if (count($parameters) == 3) {
+                                       continue 2;
+                               }
+                               $item = DBA::selectFirst('item', ['uid', 'uri-id'], ['id' => $parameters[1]]);
+                               if (!DBA::isResult($item)) {
+                                       continue 2;
+                               }
+       
+                               $parameters[1] = $item['uri-id'];
+                               $parameters[2] = $item['uid'];
+                               break;
+                       case 'delivery':
+                               if (count($parameters) == 4) {
+                                       continue 2;
+                               }
+                               $item = DBA::selectFirst('item', ['uid', 'uri-id'], ['id' => $parameters[1]]);
+                               if (!DBA::isResult($item)) {
+                                       continue 2;
+                               }
+       
+                               $parameters[1] = $item['uri-id'];
+                               $parameters[3] = $item['uid'];
+                               break;
+                       case 'apdelivery':
+                               if (count($parameters) == 6) {
+                                       continue 2;
+                               }
+       
+                               if (empty($parameters[4])) {
+                                       $parameters[4] = [];
+                               }
+       
+                               $item = DBA::selectFirst('item', ['uri-id'], ['id' => $parameters[1]]);
+                               if (!DBA::isResult($item)) {
+                                       continue 2;
+                               }
+       
+                               $parameters[5] = $item['uri-id'];
+                               break;
+                       default:
+                               continue 2;
+               }
+               DBA::update('workerqueue', ['parameter' => json_encode($parameters)], ['id' => $task['id']]);
+
+               return Update::SUCCESS;
+       }
+}
+
+function update_1407()
+{
+       if (!DBA::e("UPDATE `post` SET `causer-id` = NULL WHERE `causer-id` = 0")) {
+               return Update::FAILED;
+       }
+       if (!DBA::e("UPDATE `post-user` SET `causer-id` = NULL WHERE `causer-id` = 0")) {
+               return Update::FAILED;
+       }
+       if (!DBA::e("UPDATE `post-thread` SET `causer-id` = NULL WHERE `causer-id` = 0")) {
+               return Update::FAILED;
+       }
+       if (!DBA::e("UPDATE `post-thread-user` SET `causer-id` = NULL WHERE `causer-id` = 0")) {
+               return Update::FAILED;
+       }
+
+       return Update::SUCCESS;
+}
+
+function update_1413()
+{
+       if (!DBA::e("UPDATE `post-user` SET `post-reason` = `post-type` WHERE `post-type` >= 64 and `post-type` <= 75")) {
+               return Update::FAILED;
+       }
+}