]> git.mxchange.org Git - friendica.git/blob - update.php
Show month/halfyear usage
[friendica.git] / update.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  * Automatic post-databse structure change updates
21  *
22  * These functions are responsible for doing critical post update changes to the data (not the structure) in the database.
23  *
24  * Database structure changes are done in static/dbstructure.config.php
25  *
26  * For non-critical database migrations, please add a method in the Database\PostUpdate class
27  *
28  * If there is a need for a post update to a structure change, update this file
29  * by adding a new function at the end with the number of the new DB_UPDATE_VERSION.
30  *
31  * The numbered script in this file has to be exactly like the DB_UPDATE_VERSION
32  *
33  * Example:
34  * You are currently on version 4711 and you are preparing changes that demand an update script.
35  *
36  * 1. Create a function "update_4712()" here in the update.php
37  * 2. Apply the needed structural changes in static/dbStructure.php
38  * 3. Set DB_UPDATE_VERSION in static/dbstructure.config.php to 4712.
39  *
40  * If you need to run a script before the database update, name the function "pre_update_4712()"
41  */
42
43 use Friendica\Core\Logger;
44 use Friendica\Core\Storage\Capability\ICanReadFromStorage;
45 use Friendica\Core\Update;
46 use Friendica\Core\Worker;
47 use Friendica\Database\Database;
48 use Friendica\Database\DBA;
49 use Friendica\Database\DBStructure;
50 use Friendica\DI;
51 use Friendica\Model\Contact;
52 use Friendica\Model\Item;
53 use Friendica\Model\ItemURI;
54 use Friendica\Model\Notification;
55 use Friendica\Model\Photo;
56 use Friendica\Model\Post;
57 use Friendica\Model\Profile;
58 use Friendica\Security\PermissionSet\Repository\PermissionSet;
59 use Friendica\Worker\Delivery;
60
61 // Post-update script of PR 5751
62 function update_1298()
63 {
64         $keys = ['gender', 'marital', 'sexual'];
65         foreach ($keys as $translateKey) {
66                 $allData = DBA::select('profile', ['id', $translateKey]);
67                 $allLangs = DI::l10n()->getAvailableLanguages();
68                 $success = 0;
69                 $fail = 0;
70                 foreach ($allData as $key => $data) {
71                         $toTranslate = $data[$translateKey];
72                         if ($toTranslate != '') {
73                                 foreach ($allLangs as $key => $lang) {
74                                         $a = new \stdClass();
75                                         $a->strings = [];
76
77                                         // First we get the the localizations
78                                         if (file_exists("view/lang/$lang/strings.php")) {
79                                                 include "view/lang/$lang/strings.php";
80                                         }
81                                         if (file_exists("addon/morechoice/lang/$lang/strings.php")) {
82                                                 include "addon/morechoice/lang/$lang/strings.php";
83                                         }
84
85                                         $localizedStrings = $a->strings;
86                                         unset($a);
87
88                                         $key = array_search($toTranslate, $localizedStrings);
89                                         if ($key !== false) {
90                                                 break;
91                                         }
92
93                                         // defaulting to empty string
94                                         $key = '';
95                                 }
96
97                                 if ($key == '') {
98                                         $fail++;
99                                 } else {
100                                         DBA::update('profile', [$translateKey => $key], ['id' => $data['id']]);
101                                         Logger::notice('Updated contact', ['action' => 'update', 'contact' => $data['id'], "$translateKey" => $key,
102                                                 'was' => $data[$translateKey]]);
103
104                                         Contact::updateSelfFromUserID($data['id']);
105                                         Profile::publishUpdate($data['id']);
106                                         $success++;
107                                 }
108                         }
109                 }
110
111                 Logger::notice($translateKey . " fix completed", ['action' => 'update', 'translateKey' => $translateKey, 'Success' => $success, 'Fail' => $fail ]);
112         }
113         return Update::SUCCESS;
114 }
115
116 function update_1309()
117 {
118         $queue = DBA::select('queue', ['id', 'cid', 'guid']);
119         while ($entry = DBA::fetch($queue)) {
120                 $contact = DBA::selectFirst('contact', ['uid'], ['id' => $entry['cid']]);
121                 if (!DBA::isResult($contact)) {
122                         continue;
123                 }
124
125                 $item = Post::selectFirst(['id', 'gravity'], ['uid' => $contact['uid'], 'guid' => $entry['guid']]);
126                 if (!DBA::isResult($item)) {
127                         continue;
128                 }
129
130                 $deliver_options = ['priority' => PRIORITY_MEDIUM, 'dont_fork' => true];
131                 Worker::add($deliver_options, 'Delivery', Delivery::POST, $item['id'], $entry['cid']);
132                 Logger::info('Added delivery worker', ['item' => $item['id'], 'contact' => $entry['cid']]);
133                 DBA::delete('queue', ['id' => $entry['id']]);
134         }
135         return Update::SUCCESS;
136 }
137
138 function update_1315()
139 {
140         if (DBStructure::existsTable('item-delivery-data')) {
141                 DBA::delete('item-delivery-data', ['postopts' => '', 'inform' => '', 'queue_count' => 0, 'queue_done' => 0]);
142         }
143         return Update::SUCCESS;
144 }
145
146 function update_1318()
147 {
148         DBA::update('profile', ['marital' => "In a relation"], ['marital' => "Unavailable"]);
149         DBA::update('profile', ['marital' => "Single"], ['marital' => "Available"]);
150
151         Worker::add(PRIORITY_LOW, 'ProfileUpdate');
152         return Update::SUCCESS;
153 }
154
155 function update_1323()
156 {
157         $users = DBA::select('user', ['uid']);
158         while ($user = DBA::fetch($users)) {
159                 if (Contact::updateSelfFromUserID($user['uid'])) {
160                         Profile::publishUpdate($user['uid']);
161                 }
162         }
163         DBA::close($users);
164
165         return Update::SUCCESS;
166 }
167
168 function update_1327()
169 {
170         $contacts = DBA::select('contact', ['uid', 'id', 'blocked', 'readonly'], ["`uid` != ? AND (`blocked` OR `readonly`) AND NOT `pending`", 0]);
171         while ($contact = DBA::fetch($contacts)) {
172                 Contact\User::setBlocked($contact['id'], $contact['uid'], $contact['blocked']);
173                 Contact\User::setIgnored($contact['id'], $contact['uid'], $contact['readonly']);
174         }
175         DBA::close($contacts);
176
177         return Update::SUCCESS;
178 }
179
180 function update_1330()
181 {
182         $currStorage = DI::config()->get('storage', 'class', '');
183
184         // set the name of the storage instead of the classpath as config
185         if (!empty($currStorage)) {
186                 /** @var ICanReadFromStorage $currStorage */
187                 if (!DI::config()->set('storage', 'name', $currStorage::getName())) {
188                         return Update::FAILED;
189                 }
190
191                 // try to delete the class since it isn't needed. This won't work with config files
192                 DI::config()->delete('storage', 'class');
193         }
194
195         // Update attachments and photos
196         if (!DBA::e("UPDATE `photo` SET `photo`.`backend-class` = SUBSTR(`photo`.`backend-class`, 25) WHERE `photo`.`backend-class` LIKE 'Friendica\\\Model\\\Storage\\\%' ESCAPE '|'") ||
197             !DBA::e("UPDATE `attach` SET `attach`.`backend-class` = SUBSTR(`attach`.`backend-class`, 25) WHERE `attach`.`backend-class` LIKE 'Friendica\\\Model\\\Storage\\\%' ESCAPE '|'")) {
198                 return Update::FAILED;
199         };
200
201         return Update::SUCCESS;
202 }
203
204 function update_1332()
205 {
206         $condition = ["`is-default` IS NOT NULL"];
207         $profiles = DBA::select('profile', [], $condition);
208
209         while ($profile = DBA::fetch($profiles)) {
210                 Profile::migrate($profile);
211         }
212         DBA::close($profiles);
213
214         DBA::update('contact', ['profile-id' => null], ['`profile-id` IS NOT NULL']);
215
216         return Update::SUCCESS;
217 }
218
219 function update_1347()
220 {
221         foreach (Item::ACTIVITIES as $index => $activity) {
222                 DBA::insert('verb', ['id' => $index + 1, 'name' => $activity], Database::INSERT_IGNORE);
223         }
224
225         return Update::SUCCESS;
226 }
227
228 function pre_update_1348()
229 {
230         if (!DBA::exists('contact', ['id' => 0])) {
231                 DBA::insert('contact', ['nurl' => '']);
232                 $lastid = DBA::lastInsertId();
233                 if ($lastid != 0) {
234                         DBA::update('contact', ['id' => 0], ['id' => $lastid]);
235                 }
236         }
237
238         // The tables "permissionset" and "tag" could or could not exist during the update.
239         // This depends upon the previous version. Depending upon this situation we have to add
240         // the "0" values before adding the foreign keys - or after would be sufficient.
241
242         update_1348();
243
244         if (DBStructure::existsTable('auth_codes') && DBStructure::existsTable('clients')) {
245                 DBA::e("DELETE FROM `auth_codes` WHERE NOT `client_id` IN (SELECT `client_id` FROM `clients`)");
246         }
247         if (DBStructure::existsTable('tokens') && DBStructure::existsTable('clients')) {
248                 DBA::e("DELETE FROM `tokens` WHERE NOT `client_id` IN (SELECT `client_id` FROM `clients`)");
249         }
250         return Update::SUCCESS;
251 }
252
253 function update_1348()
254 {
255         // Insert a permissionset with id=0
256         // Inserting it without an ID and then changing the value to 0 tricks the auto increment
257         if (!DBA::exists('permissionset', ['id' => 0])) {
258                 DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']);
259                 $lastid = DBA::lastInsertId();
260                 if ($lastid != 0) {
261                         DBA::update('permissionset', ['id' => 0], ['id' => $lastid]);
262                 }
263         }
264
265         if (!DBA::exists('tag', ['id' => 0])) {
266                 DBA::insert('tag', ['name' => '']);
267                 $lastid = DBA::lastInsertId();
268                 if ($lastid != 0) {
269                         DBA::update('tag', ['id' => 0], ['id' => $lastid]);
270                 }
271         }
272
273         return Update::SUCCESS;
274 }
275
276 function update_1349()
277 {
278         if (!DBStructure::existsTable('item-activity')) {
279                 return Update::SUCCESS;
280         }
281
282         $correct = true;
283         foreach (Item::ACTIVITIES as $index => $activity) {
284                 if (!DBA::exists('verb', ['id' => $index + 1, 'name' => $activity])) {
285                         $correct = false;
286                 }
287         }
288
289         if (!$correct) {
290                 // The update failed - but it cannot be recovered, since the data doesn't match our expectation
291                 // This means that we can't use this "shortcut" to fill the "vid" field and we have to rely upon
292                 // the postupdate. This is not fatal, but means that it will take some longer time for the system
293                 // to fill all data.
294                 return Update::SUCCESS;
295         }
296
297         if (!DBA::e("UPDATE `item` INNER JOIN `item-activity` ON `item`.`uri-id` = `item-activity`.`uri-id`
298                 SET `vid` = `item-activity`.`activity` + 1 WHERE `gravity` = ? AND (`vid` IS NULL OR `vid` = 0)", GRAVITY_ACTIVITY)) {
299                 return Update::FAILED;
300         }
301
302         return Update::SUCCESS;
303 }
304
305 function update_1351()
306 {
307         if (DBStructure::existsTable('thread') && !DBA::e("UPDATE `thread` INNER JOIN `item` ON `thread`.`iid` = `item`.`id` SET `thread`.`uri-id` = `item`.`uri-id`")) {
308                 return Update::FAILED;
309         }
310
311         return Update::SUCCESS;
312 }
313
314 function pre_update_1354()
315 {
316         if (DBStructure::existsColumn('contact', ['ffi_keyword_blacklist'])
317                 && !DBStructure::existsColumn('contact', ['ffi_keyword_denylist'])
318                 && !DBA::e("ALTER TABLE `contact` CHANGE `ffi_keyword_blacklist` `ffi_keyword_denylist` text null")) {
319                 return Update::FAILED;
320         }
321         return Update::SUCCESS;
322 }
323
324 function update_1354()
325 {
326         if (DBStructure::existsColumn('contact', ['ffi_keyword_blacklist'])
327                 && DBStructure::existsColumn('contact', ['ffi_keyword_denylist'])) {
328                 if (!DBA::e("UPDATE `contact` SET `ffi_keyword_denylist` = `ffi_keyword_blacklist`")) {
329                         return Update::FAILED;
330                 }
331
332                 // When the data had been copied then the main task is done.
333                 // Having the old field removed is only beauty but not crucial.
334                 // So we don't care if this was successful or not.
335                 DBA::e("ALTER TABLE `contact` DROP `ffi_keyword_blacklist`");
336         }
337         return Update::SUCCESS;
338 }
339
340 function update_1357()
341 {
342         if (!DBA::e("UPDATE `contact` SET `failed` = true WHERE `success_update` < `failure_update` AND `failed` IS NULL")) {
343                 return Update::FAILED;
344         }
345
346         if (!DBA::e("UPDATE `contact` SET `failed` = false WHERE `success_update` > `failure_update` AND `failed` IS NULL")) {
347                 return Update::FAILED;
348         }
349
350         if (!DBA::e("UPDATE `contact` SET `failed` = false WHERE `updated` > `failure_update` AND `failed` IS NULL")) {
351                 return Update::FAILED;
352         }
353
354         if (!DBA::e("UPDATE `contact` SET `failed` = false WHERE `last-item` > `failure_update` AND `failed` IS NULL")) {
355                 return Update::FAILED;
356         }
357
358         if (!DBA::e("UPDATE `gserver` SET `failed` = true WHERE `last_contact` < `last_failure` AND `failed` IS NULL")) {
359                 return Update::FAILED;
360         }
361
362         if (!DBA::e("UPDATE `gserver` SET `failed` = false WHERE `last_contact` > `last_failure` AND `failed` IS NULL")) {
363                 return Update::FAILED;
364         }
365
366         return Update::SUCCESS;
367 }
368
369 function pre_update_1358()
370 {
371         if (!DBA::e("DELETE FROM `contact-relation` WHERE NOT `relation-cid` IN (SELECT `id` FROM `contact`) OR NOT `cid` IN (SELECT `id` FROM `contact`)")) {
372                 return Update::FAILED;
373         }
374
375         return Update::SUCCESS;
376 }
377
378 function pre_update_1363()
379 {
380         Photo::delete(["`contact-id` != ? AND NOT `contact-id` IN (SELECT `id` FROM `contact`)", 0]);
381         return Update::SUCCESS;
382 }
383
384 function pre_update_1364()
385 {
386         if (!DBA::e("DELETE FROM `2fa_recovery_codes` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
387                 return Update::FAILED;
388         }
389
390         if (!DBA::e("DELETE FROM `2fa_app_specific_password` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
391                 return Update::FAILED;
392         }
393
394         if (!DBA::e("DELETE FROM `attach` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
395                 return Update::FAILED;
396         }
397
398         if (DBStructure::existsTable('clients') && !DBA::e("DELETE FROM `clients` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
399                 return Update::FAILED;
400         }
401
402         if (!DBA::e("DELETE FROM `conv` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
403                 return Update::FAILED;
404         }
405
406         if (!DBA::e("DELETE FROM `fsuggest` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
407                 return Update::FAILED;
408         }
409
410         if (!DBA::e("DELETE FROM `group` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
411                 return Update::FAILED;
412         }
413
414         if (!DBA::e("DELETE FROM `intro` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
415                 return Update::FAILED;
416         }
417
418         if (!DBA::e("DELETE FROM `manage` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
419                 return Update::FAILED;
420         }
421
422         if (!DBA::e("DELETE FROM `manage` WHERE NOT `mid` IN (SELECT `uid` FROM `user`)")) {
423                 return Update::FAILED;
424         }
425
426         if (!DBA::e("DELETE FROM `mail` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
427                 return Update::FAILED;
428         }
429
430         if (!DBA::e("DELETE FROM `mailacct` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
431                 return Update::FAILED;
432         }
433
434         if (!DBA::e("DELETE FROM `notify` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
435                 return Update::FAILED;
436         }
437
438         if (!DBA::e("DELETE FROM `openwebauth-token` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
439                 return Update::FAILED;
440         }
441
442         if (!DBA::e("DELETE FROM `pconfig` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
443                 return Update::FAILED;
444         }
445
446         if (!DBA::e("DELETE FROM `profile` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
447                 return Update::FAILED;
448         }
449
450         if (DBStructure::existsTable('profile_check') && !DBA::e("DELETE FROM `profile_check` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
451                 return Update::FAILED;
452         }
453
454         if (!DBA::e("DELETE FROM `profile_field` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
455                 return Update::FAILED;
456         }
457
458         if (!DBA::e("DELETE FROM `push_subscriber` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
459                 return Update::FAILED;
460         }
461
462         if (!DBA::e("DELETE FROM `register` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
463                 return Update::FAILED;
464         }
465
466         if (!DBA::e("DELETE FROM `search` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
467                 return Update::FAILED;
468         }
469
470         if (DBStructure::existsTable('tokens') && !DBA::e("DELETE FROM `tokens` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
471                 return Update::FAILED;
472         }
473
474         if (!DBA::e("DELETE FROM `user-contact` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
475                 return Update::FAILED;
476         }
477
478         if (DBStructure::existsTable('user-item') && !DBA::e("DELETE FROM `user-item` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
479                 return Update::FAILED;
480         }
481
482         if (!DBA::e("DELETE FROM `notify-threads` WHERE NOT `receiver-uid` IN (SELECT `uid` FROM `user`)")) {
483                 return Update::FAILED;
484         }
485
486         if (!DBA::e("DELETE FROM `event` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) {
487                 return Update::FAILED;
488         }
489
490         if (!DBA::e("DELETE FROM `fsuggest` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) {
491                 return Update::FAILED;
492         }
493
494         if (!DBA::e("DELETE FROM `group_member` WHERE NOT `contact-id` IN (SELECT `id` FROM `contact`)")) {
495                 return Update::FAILED;
496         }
497
498         if (!DBA::e("DELETE FROM `intro` WHERE NOT `contact-id` IN (SELECT `id` FROM `contact`)")) {
499                 return Update::FAILED;
500         }
501
502         if (DBStructure::existsTable('profile_check') && !DBA::e("DELETE FROM `profile_check` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) {
503                 return Update::FAILED;
504         }
505
506         if (!DBA::e("DELETE FROM `user-contact` WHERE NOT `cid` IN (SELECT `id` FROM `contact`)")) {
507                 return Update::FAILED;
508         }
509
510         if (!DBA::e("DELETE FROM `group_member` WHERE NOT `gid` IN (SELECT `id` FROM `group`)")) {
511                 return Update::FAILED;
512         }
513
514         if (!DBA::e("DELETE FROM `gserver-tag` WHERE NOT `gserver-id` IN (SELECT `id` FROM `gserver`)")) {
515                 return Update::FAILED;
516         }
517
518         if (DBStructure::existsTable('user-item') && !DBA::e("DELETE FROM `user-item` WHERE NOT `iid` IN (SELECT `id` FROM `item`)")) {
519                 return Update::FAILED;
520         }
521
522         return Update::SUCCESS;
523 }
524
525 function pre_update_1365()
526 {
527         if (!DBA::e("DELETE FROM `notify-threads` WHERE NOT `notify-id` IN (SELECT `id` FROM `notify`)")) {
528                 return Update::FAILED;
529         }
530
531         if (DBStructure::existsTable('thread') && !DBA::e("DELETE FROM `thread` WHERE NOT `iid` IN (SELECT `id` FROM `item`)")) {
532                 return Update::FAILED;
533         }
534
535         return Update::SUCCESS;
536 }
537
538 function update_1375()
539 {
540         if (!DBA::e("UPDATE `item` SET `thr-parent` = `parent-uri`, `thr-parent-id` = `parent-uri-id` WHERE `thr-parent` = ''")) {
541                 return Update::FAILED;
542         }
543
544         return Update::SUCCESS;
545 }
546
547 function pre_update_1376()
548 {
549         // Insert a user with uid=0
550         DBStructure::checkInitialValues();
551
552         if (!DBA::e("DELETE FROM `item` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
553                 return Update::FAILED;
554         }
555
556         if (!DBA::e("DELETE FROM `event` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
557                 return Update::FAILED;
558         }
559
560         if (DBStructure::existsTable('thread') && !DBA::e("DELETE FROM `thread` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
561                 return Update::FAILED;
562         }
563
564         if (!DBA::e("DELETE FROM `permissionset` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
565                 return Update::FAILED;
566         }
567
568         if (!DBA::e("DELETE FROM `openwebauth-token` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
569                 return Update::FAILED;
570         }
571
572         if (!DBA::e("DELETE FROM `post-category` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
573                 return Update::FAILED;
574         }
575
576         Photo::delete(["NOT `uid` IN (SELECT `uid` FROM `user`)"]);
577
578         if (!DBA::e("DELETE FROM `contact` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) {
579                 return Update::FAILED;
580         }
581
582         return Update::SUCCESS;
583 }
584
585 function pre_update_1377()
586 {
587         DBStructure::checkInitialValues();
588
589         if (!DBA::e("DELETE FROM `item` WHERE NOT `author-id` IN (SELECT `id` FROM `contact`)")) {
590                 return Update::FAILED;
591         }
592
593         if (!DBA::e("DELETE FROM `item` WHERE NOT `owner-id` IN (SELECT `id` FROM `contact`)")) {
594                 return Update::FAILED;
595         }
596
597         if (!DBA::e("UPDATE `item` SET `contact-id` = `owner-id` WHERE NOT `contact-id` IN (SELECT `id` FROM `contact`)")) {
598                 return Update::FAILED;
599         }
600
601         if (DBStructure::existsTable('thread') && !DBA::e("DELETE FROM `thread` WHERE NOT `author-id` IN (SELECT `id` FROM `contact`)")) {
602                 return Update::FAILED;
603         }
604
605         if (DBStructure::existsTable('thread') && !DBA::e("DELETE FROM `thread` WHERE NOT `owner-id` IN (SELECT `id` FROM `contact`)")) {
606                 return Update::FAILED;
607         }
608
609         if (DBStructure::existsTable('thread') && !DBA::e("UPDATE `thread` SET `contact-id` = `owner-id` WHERE NOT `contact-id` IN (SELECT `id` FROM `contact`)")) {
610                 return Update::FAILED;
611         }
612
613         if (!DBA::e("UPDATE `notify` SET `uri-id` = NULL WHERE `uri-id` = 0")) {
614                 return Update::FAILED;
615         }
616
617         if (DBStructure::existsTable('diaspora-interaction') && !DBA::e("DELETE FROM `diaspora-interaction` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) {
618                 return Update::FAILED;
619         }
620
621         if (DBStructure::existsTable('item-activity') && !DBA::e("DELETE FROM `item-activity` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) {
622                 return Update::FAILED;
623         }
624
625         if (DBStructure::existsTable('item-content') && !DBA::e("DELETE FROM `item-content` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) {
626                 return Update::FAILED;
627         }
628
629         if (!DBA::e("DELETE FROM `notify` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) {
630                 return Update::FAILED;
631         }
632
633         if (!DBA::e("UPDATE `notify` SET `parent-uri-id` = NULL WHERE `parent-uri-id` = 0")) {
634                 return Update::FAILED;
635         }
636         if (!DBA::e("DELETE FROM `notify` WHERE `parent-uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) {
637                 return Update::FAILED;
638         }
639
640         if (!DBA::e("UPDATE `notify-threads` SET `master-parent-uri-id` = NULL WHERE `master-parent-uri-id` = 0")) {
641                 return Update::FAILED;
642         }
643
644         if (!DBA::e("DELETE FROM `notify-threads` WHERE `master-parent-uri-id` NOT IN (SELECT `id` FROM `item-uri`)")) {
645                 return Update::FAILED;
646         }
647
648         if (!DBA::e("DELETE FROM `notify-threads` WHERE `master-parent-item` NOT IN (SELECT `id` FROM `item`)")) {
649                 return Update::FAILED;
650         }
651
652         return Update::SUCCESS;
653 }
654
655 function update_1380()
656 {
657         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 (?, ?)",
658                 Notification\ObjectType::ITEM, Notification\ObjectType::PERSON)) {
659                 return Update::FAILED;
660         }
661
662         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 (?, ?)",
663                 Notification\ObjectType::ITEM, Notification\ObjectType::PERSON)) {
664                 return Update::FAILED;
665         }
666
667         return Update::SUCCESS;
668 }
669
670 function pre_update_1395()
671 {
672         if (DBStructure::existsTable('post-user') && !DBStructure::existsColumn('post-user', ['id']) && !DBA::e("DROP TABLE `post-user`")) {
673                 return Update::FAILED;
674         }
675         return Update::SUCCESS;
676 }
677
678 function update_1395()
679 {
680         if (!DBA::e("INSERT INTO `post-user`(`id`, `uri-id`, `uid`, `contact-id`, `unseen`, `origin`, `psid`)
681                 SELECT `id`, `uri-id`, `uid`, `contact-id`, `unseen`, `origin`, `psid` FROM `item`
682                 ON DUPLICATE KEY UPDATE `contact-id` = `item`.`contact-id`, `unseen` = `item`.`unseen`, `origin` = `item`.`origin`, `psid` = `item`.`psid`")) {
683                 return Update::FAILED;
684         }
685
686         if (DBStructure::existsTable('user-item') && !DBA::e("INSERT INTO `post-user`(`uri-id`, `uid`, `hidden`, `notification-type`)
687                 SELECT `uri-id`, `user-item`.`uid`, `hidden`,`notification-type` FROM `user-item`
688                         INNER JOIN `item` ON `item`.`id` = `user-item`.`iid`
689                 ON DUPLICATE KEY UPDATE `hidden` = `user-item`.`hidden`, `notification-type` = `user-item`.`notification-type`")) {
690                 return Update::FAILED;
691         }
692         return Update::SUCCESS;
693 }
694
695 function update_1396()
696 {
697         if (!DBStructure::existsTable('item-content')) {
698                 return Update::SUCCESS;
699         }
700
701         if (DBStructure::existsColumn('item-content', ['raw-body'])) {
702                 if (!DBA::e("INSERT IGNORE INTO `post-content`(`uri-id`, `title`, `content-warning`, `body`, `raw-body`,
703                         `location`, `coord`, `language`, `app`, `rendered-hash`, `rendered-html`,
704                         `object-type`, `object`, `target-type`, `target`, `resource-id`, `plink`)
705                         SELECT `item-content`.`uri-id`, `item-content`.`title`, `item-content`.`content-warning`,
706                                 `item-content`.`body`, `item-content`.`raw-body`, `item-content`.`location`, `item-content`.`coord`,
707                                 `item-content`.`language`, `item-content`.`app`, `item-content`.`rendered-hash`,
708                                 `item-content`.`rendered-html`, `item-content`.`object-type`, `item-content`.`object`,
709                                 `item-content`.`target-type`, `item-content`.`target`, `item`.`resource-id`, `item-content`.`plink`
710                                 FROM `item-content` INNER JOIN `item` ON `item`.`uri-id` = `item-content`.`uri-id`")) {
711                         return Update::FAILED;
712                 }
713         } else {
714                 if (!DBA::e("INSERT IGNORE INTO `post-content`(`uri-id`, `title`, `content-warning`, `body`,
715                         `location`, `coord`, `language`, `app`, `rendered-hash`, `rendered-html`,
716                         `object-type`, `object`, `target-type`, `target`, `resource-id`, `plink`)
717                         SELECT `item-content`.`uri-id`, `item-content`.`title`, `item-content`.`content-warning`,
718                                 `item-content`.`body`, `item-content`.`location`, `item-content`.`coord`,
719                                 `item-content`.`language`, `item-content`.`app`, `item-content`.`rendered-hash`,
720                                 `item-content`.`rendered-html`, `item-content`.`object-type`, `item-content`.`object`,
721                                 `item-content`.`target-type`, `item-content`.`target`, `item`.`resource-id`, `item-content`.`plink`
722                                 FROM `item-content` INNER JOIN `item` ON `item`.`uri-id` = `item-content`.`uri-id`")) {
723                         return Update::FAILED;
724                 }
725         }
726         return Update::SUCCESS;
727 }
728
729 function update_1397()
730 {
731         if (!DBA::e("INSERT INTO `post-user-notification`(`uri-id`, `uid`, `notification-type`)
732                 SELECT `uri-id`, `uid`, `notification-type` FROM `post-user` WHERE `notification-type` != 0
733                 ON DUPLICATE KEY UPDATE `uri-id` = `post-user`.`uri-id`, `uid` = `post-user`.`uid`, `notification-type` = `post-user`.`notification-type`")) {
734                 return Update::FAILED;
735         }
736
737         if (!DBStructure::existsTable('user-item')) {
738                 return Update::SUCCESS;
739         }
740
741         if (!DBA::e("INSERT INTO `post-user-notification`(`uri-id`, `uid`, `notification-type`)
742                 SELECT `uri-id`, `user-item`.`uid`, `notification-type` FROM `user-item`
743                         INNER JOIN `item` ON `item`.`id` = `user-item`.`iid` WHERE `notification-type` != 0
744                 ON DUPLICATE KEY UPDATE `notification-type` = `user-item`.`notification-type`")) {
745                 return Update::FAILED;
746         }
747
748         if (!DBStructure::existsTable('thread')) {
749                 return Update::SUCCESS;
750         }
751
752         if (!DBA::e("INSERT IGNORE INTO `post-thread-user`(`uri-id`, `uid`, `pinned`, `starred`, `ignored`, `wall`, `pubmail`, `forum_mode`)
753                 SELECT `thread`.`uri-id`, `thread`.`uid`, `user-item`.`pinned`, `thread`.`starred`,
754                         `thread`.`ignored`, `thread`.`wall`, `thread`.`pubmail`, `thread`.`forum_mode`
755                 FROM `thread` LEFT JOIN `user-item` ON `user-item`.`iid` = `thread`.`iid`")) {
756                 return Update::FAILED;
757         }
758
759         return Update::SUCCESS;
760 }
761
762 function update_1398()
763 {
764         if (!DBStructure::existsTable('thread')) {
765                 return Update::SUCCESS;
766         }
767
768         if (!DBA::e("INSERT IGNORE INTO `post-thread` (`uri-id`, `owner-id`, `author-id`, `network`, `created`, `received`, `changed`, `commented`)
769                 SELECT `uri-id`, `owner-id`, `author-id`, `network`, `created`, `received`, `changed`, `commented` FROM `thread`")) {
770                         return Update::FAILED;
771         }
772
773         if (!DBStructure::existsTable('thread')) {
774                 return Update::SUCCESS;
775         }
776
777         if (!DBA::e("UPDATE `post-thread-user` INNER JOIN `thread` ON `thread`.`uid` = `post-thread-user`.`uid` AND `thread`.`uri-id` = `post-thread-user`.`uri-id`
778                 SET `post-thread-user`.`mention` = `thread`.`mention`")) {
779                         return Update::FAILED;
780         }
781
782         return Update::SUCCESS;
783 }
784
785 function update_1399()
786 {
787         if (!DBA::e("UPDATE `post-thread-user` INNER JOIN `post-user` ON `post-user`.`uid` = `post-thread-user`.`uid` AND `post-user`.`uri-id` = `post-thread-user`.`uri-id`
788                 SET `post-thread-user`.`contact-id` = `post-user`.`contact-id`, `post-thread-user`.`unseen` = `post-user`.`unseen`,
789                 `post-thread-user`.`hidden` = `post-user`.`hidden`, `post-thread-user`.`origin` = `post-user`.`origin`,
790                 `post-thread-user`.`psid` = `post-user`.`psid`, `post-thread-user`.`post-user-id` = `post-user`.`id`")) {
791                         return Update::FAILED;
792         }
793
794         return Update::SUCCESS;
795 }
796
797 function update_1400()
798 {
799         if (!DBA::e("INSERT IGNORE INTO `post` (`uri-id`, `parent-uri-id`, `thr-parent-id`, `owner-id`, `author-id`, `network`,
800                 `created`, `received`, `edited`, `gravity`, `causer-id`, `post-type`, `vid`, `private`, `visible`, `deleted`, `global`)
801                 SELECT `uri-id`, `parent-uri-id`, `thr-parent-id`, `owner-id`, `author-id`, `network`, `created`, `received`, `edited`,
802                         `gravity`, `causer-id`, `post-type`, `vid`, `private`, `visible`, `deleted`, `global` FROM `item`")) {
803                         return Update::FAILED;
804         }
805
806         if (!DBA::e("UPDATE `post-user` INNER JOIN `item` ON `item`.`uri-id` = `post-user`.`uri-id` AND `item`.`uid` = `post-user`.`uid`
807                 INNER JOIN `event` ON `item`.`event-id` = `event`.`id` AND `event`.`id` != 0
808                 SET `post-user`.`event-id` = `item`.`event-id`")) {
809                 return Update::FAILED;
810         }
811
812         if (!DBA::e("UPDATE `post-user` INNER JOIN `item` ON `item`.`uri-id` = `post-user`.`uri-id` AND `item`.`uid` = `post-user`.`uid`
813                 SET `post-user`.`wall` = `item`.`wall`, `post-user`.`parent-uri-id` = `item`.`parent-uri-id`,
814                 `post-user`.`thr-parent-id` = `item`.`thr-parent-id`,
815                 `post-user`.`created` = `item`.`created`, `post-user`.`edited` = `item`.`edited`,
816                 `post-user`.`received` = `item`.`received`, `post-user`.`gravity` = `item`.`gravity`,
817                 `post-user`.`network` = `item`.`network`, `post-user`.`owner-id` = `item`.`owner-id`,
818                 `post-user`.`author-id` = `item`.`author-id`, `post-user`.`causer-id` = `item`.`causer-id`,
819                 `post-user`.`post-type` = `item`.`post-type`, `post-user`.`vid` = `item`.`vid`,
820                 `post-user`.`private` = `item`.`private`, `post-user`.`global` = `item`.`global`,
821                 `post-user`.`visible` = `item`.`visible`, `post-user`.`deleted` = `item`.`deleted`")) {
822                 return Update::FAILED;
823         }
824
825         if (!DBA::e("INSERT IGNORE INTO `post-thread-user` (`uri-id`, `owner-id`, `author-id`, `causer-id`, `network`,
826                 `created`, `received`, `changed`, `commented`, `uid`,  `wall`, `contact-id`, `unseen`, `hidden`, `origin`, `psid`, `post-user-id`)
827                 SELECT `uri-id`, `owner-id`, `author-id`, `causer-id`, `network`, `created`, `received`, `received`, `received`,
828                         `uid`, `wall`, `contact-id`, `unseen`, `hidden`, `origin`, `psid`, `id`
829                 FROM `post-user` WHERE `gravity` = 0 AND NOT EXISTS(SELECT `uri-id` FROM `post-thread-user` WHERE `post-user-id` = `post-user`.id)")) {
830                 return Update::FAILED;
831         }
832
833         if (!DBA::e("UPDATE `post-thread-user` INNER JOIN `post-thread` ON `post-thread-user`.`uri-id` = `post-thread`.`uri-id`
834                 SET `post-thread-user`.`owner-id` = `post-thread`.`owner-id`, `post-thread-user`.`author-id` = `post-thread`.`author-id`,
835                 `post-thread-user`.`causer-id` = `post-thread`.`causer-id`, `post-thread-user`.`network` = `post-thread`.`network`,
836                 `post-thread-user`.`created` = `post-thread`.`created`, `post-thread-user`.`received` = `post-thread`.`received`,
837                 `post-thread-user`.`changed` = `post-thread`.`changed`, `post-thread-user`.`commented` = `post-thread`.`commented`")) {
838                 return Update::FAILED;
839         }
840
841         return Update::SUCCESS;
842 }
843
844 function pre_update_1403()
845 {
846         // Necessary before a primary key change
847         if (DBStructure::existsTable('parsed_url') && !DBA::e("DROP TABLE `parsed_url`")) {
848                 return Update::FAILED;
849         }
850
851         return Update::SUCCESS;
852 }
853
854 function update_1404()
855 {
856         $tasks = DBA::select('workerqueue', ['id', 'command', 'parameter'], ['command' => ['notifier', 'delivery', 'apdelivery', 'done' => false]]);
857         while ($task = DBA::fetch($tasks)) {
858                 $parameters = json_decode($task['parameter'], true);
859
860                 if (is_array($parameters) && count($parameters) && in_array($parameters[0], [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
861                         continue;
862                 }
863
864                 switch (strtolower($task['command'])) {
865                         case 'notifier':
866                                 if (count($parameters) == 3) {
867                                         continue 2;
868                                 }
869                                 $item = DBA::selectFirst('item', ['uid', 'uri-id'], ['id' => $parameters[1]]);
870                                 if (!DBA::isResult($item)) {
871                                         continue 2;
872                                 }
873
874                                 $parameters[1] = $item['uri-id'];
875                                 $parameters[2] = $item['uid'];
876                                 break;
877                         case 'delivery':
878                                 if (count($parameters) == 4) {
879                                         continue 2;
880                                 }
881                                 $item = DBA::selectFirst('item', ['uid', 'uri-id'], ['id' => $parameters[1]]);
882                                 if (!DBA::isResult($item)) {
883                                         continue 2;
884                                 }
885
886                                 $parameters[1] = $item['uri-id'];
887                                 $parameters[3] = $item['uid'];
888                                 break;
889                         case 'apdelivery':
890                                 if (count($parameters) == 6) {
891                                         continue 2;
892                                 }
893
894                                 if (empty($parameters[4])) {
895                                         $parameters[4] = [];
896                                 }
897
898                                 $item = DBA::selectFirst('item', ['uri-id'], ['id' => $parameters[1]]);
899                                 if (!DBA::isResult($item)) {
900                                         continue 2;
901                                 }
902
903                                 $parameters[5] = $item['uri-id'];
904                                 break;
905                         default:
906                                 continue 2;
907                 }
908                 DBA::update('workerqueue', ['parameter' => json_encode($parameters)], ['id' => $task['id']]);
909
910                 return Update::SUCCESS;
911         }
912 }
913
914 function update_1407()
915 {
916         if (!DBA::e("UPDATE `post` SET `causer-id` = NULL WHERE `causer-id` = 0")) {
917                 return Update::FAILED;
918         }
919         if (!DBA::e("UPDATE `post-user` SET `causer-id` = NULL WHERE `causer-id` = 0")) {
920                 return Update::FAILED;
921         }
922         if (!DBA::e("UPDATE `post-thread` SET `causer-id` = NULL WHERE `causer-id` = 0")) {
923                 return Update::FAILED;
924         }
925         if (!DBA::e("UPDATE `post-thread-user` SET `causer-id` = NULL WHERE `causer-id` = 0")) {
926                 return Update::FAILED;
927         }
928
929         return Update::SUCCESS;
930 }
931
932 function update_1413()
933 {
934         if (!DBA::e("UPDATE `post-user` SET `post-reason` = `post-type` WHERE `post-type` >= 64 and `post-type` <= 75")) {
935                 return Update::FAILED;
936         }
937 }
938
939 function update_1419()
940 {
941         $mails = DBA::select('mail', ['id', 'from-url', 'uri', 'parent-uri', 'guid'], [], ['order' => ['id']]);
942         while ($mail = DBA::fetch($mails)) {
943                 $fields = [];
944                 $fields['author-id'] = Contact::getIdForURL($mail['from-url'], 0, false);
945                 if (empty($fields['author-id'])) {
946                         continue;
947                 }
948
949                 $fields['uri-id']        = ItemURI::insert(['uri' => $mail['uri'], 'guid' => $mail['guid']]);
950                 $fields['parent-uri-id'] = ItemURI::getIdByURI($mail['parent-uri']);
951
952                 $reply = DBA::selectFirst('mail', ['uri', 'uri-id', 'guid'], ['parent-uri' => $mail['parent-uri'], 'reply' => false]);
953                 if (!empty($reply)) {
954                         $fields['thr-parent'] = $reply['uri'];
955                         if (!empty($reply['uri-id'])) {
956                                 $fields['thr-parent-id'] = $reply['uri-id'];
957                         } else {
958                                 $fields['thr-parent-id'] = ItemURI::insert(['uri' => $reply['uri'], 'guid' => $reply['guid']]);
959                         }
960                 }
961
962                 DBA::update('mail', $fields, ['id' => $mail['id']]);
963         }
964         return Update::SUCCESS;
965 }
966
967 function update_1429()
968 {
969         if (!DBA::e("UPDATE `contact` SET `uri-id` = null WHERE NOT `uri-id` IS NULL")) {
970                 return Update::FAILED;
971         }
972
973         if (!DBA::e("UPDATE `fcontact` SET `uri-id` = null WHERE NOT `uri-id` IS NULL")) {
974                 return Update::FAILED;
975         }
976
977         if (!DBA::e("UPDATE `apcontact` SET `uri-id` = null WHERE NOT `uri-id` IS NULL")) {
978                 return Update::FAILED;
979         }
980
981         DI::config()->set("system", "post_update_version", 1423);
982
983         return Update::SUCCESS;
984 }
985
986 function update_1434()
987 {
988         $name = DI::config()->get('storage', 'name');
989
990         // in case of an empty config, set "Database" as default storage backend
991         if (empty($name)) {
992                 DI::config()->set('storage', 'name', \Friendica\Core\Storage\Type\Database::getName());
993         }
994
995         // In case of a Using deprecated storage class value, set the right name for it
996         if (stristr($name, 'Friendica\Model\Storage\\')) {
997                 DI::config()->set('storage', 'name', substr($name, 24));
998         }
999
1000         return Update::SUCCESS;
1001 }
1002
1003 function update_1438()
1004 {
1005         DBA::update('photo', ['photo-type' => Photo::USER_AVATAR], ['profile' => true]);
1006         DBA::update('photo', ['photo-type' => Photo::CONTACT_AVATAR], ["NOT `profile` AND NOT `contact-id` IS NULL AND `contact-id` != ?", 0]);
1007         DBA::update('photo', ['photo-type' => Photo::DEFAULT], ["NOT `profile` AND (`contact-id` IS NULL OR `contact-id` = ?) AND `photo-type` IS NULL AND `album` != ?", 0, Photo::CONTACT_PHOTOS]);
1008 }
1009
1010 function update_1439()
1011 {
1012         $intros = DBA::select('intro', ['id', 'fid'], ["NOT `fid` IS NULL AND `fid` != ?", 0]);
1013         while ($intro = DBA::fetch($intros)) {
1014                 $fcontact = DBA::selectFirst('fcontact', ['url'], ['id' => $intro['fid']]);
1015                 if (!empty($fcontact['url'])) {
1016                         $id = Contact::getIdForURL($fcontact['url']);
1017                         if (!empty($id)) {
1018                                 DBA::update('intro',['suggest-cid' => $id], ['id' => $intro['id']]);
1019                         }
1020                 }
1021         }
1022         DBA::close($intros);
1023 }
1024
1025 function update_1440()
1026 {
1027         // Fix wrong public permissionset
1028         DBA::p("UPDATE `profile_field` SET `psid` = ? WHERE psid IN (SELECT `id` FROM `permissionset` WHERE `id` != ? AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '')", PermissionSet::PUBLIC, PermissionSet::PUBLIC);
1029         DBA::delete('permissionset', ["`id` != ? AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = ''", PermissionSet::PUBLIC]);
1030
1031         return Update::SUCCESS;
1032 }
1033
1034 function update_1441()
1035 {
1036         $languages = DI::l10n()->getAvailableLanguages();
1037
1038         $albums = [Photo::PROFILE_PHOTOS];
1039         foreach ($languages as $language) {
1040                 $albums[] = DI::l10n()->withLang($language)->t(Photo::PROFILE_PHOTOS);
1041         }
1042         $albums = array_unique($albums);
1043
1044         Photo::update(['photo-type' => Photo::USER_AVATAR], ['album' => $albums]);
1045
1046         return Update::SUCCESS;
1047 }
1048
1049 function update_1442()
1050 {
1051         // transform blocked intros into ignored intros
1052         DBA::update('intro', ['ignore' => 1, 'blocked' => 0], ['blocked' => 1]);
1053
1054         return Update::SUCCESS;
1055 }
1056
1057 /**
1058  * A bug in Contact\User::updateByContactUpdate prevented any update to the user-contact table since the rows have been
1059  * created in version 1435. This version fixes this bug but the user-contact rows are outdated, we need to regenerate
1060  * them.
1061  */
1062 function update_1444()
1063 {
1064         DBA::e('TRUNCATE TABLE `user-contact`');
1065
1066         $contacts = DBA::select('contact', [], ["`uid` != ?", 0]);
1067         while ($contact = DBA::fetch($contacts)) {
1068                 Contact\User::insertForContactArray($contact);
1069         }
1070
1071         return Update::SUCCESS;
1072 }
1073
1074 function update_1446()
1075 {
1076         $distributed_cache_driver_source = DI::config()->getCache()->getSource('system', 'distributed_cache_driver');
1077         $cache_driver_source = DI::config()->getCache()->getSource('system', 'cache_driver');
1078
1079         // In case the distributed cache driver is the default value, but the current cache driver isn't default,
1080         // we assume that the distributed cache driver should be the same as the current cache driver
1081         if (
1082                 $distributed_cache_driver_source === \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC
1083                 && $cache_driver_source > \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC
1084         ) {
1085                 DI::config()->set('system', 'distributed_cache_driver', DI::config()->get('system', 'cache_driver'));
1086         }
1087
1088         return Update::SUCCESS;
1089 }