Merge pull request #10130 from annando/bbcode
[friendica.git/.git] / update.php
index 6f796cd..819085f 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
  *
@@ -817,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;
+       }
+}