<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
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;
+ }
+}