]> git.mxchange.org Git - friendica.git/blobdiff - src/Database/PostUpdate.php
Merge pull request #9146 from tobiasd/2020.09-CHANGELOG
[friendica.git] / src / Database / PostUpdate.php
index de584238da93dc8d1f749efd1cc6905c42aad88d..a418a7948dd5c99d6ecbb74dcf3f1cc30573e58f 100644 (file)
@@ -93,9 +93,6 @@ class PostUpdate
                if (!self::update1349()) {
                        return false;
                }
-               if (!self::update1350()) {
-                       return false;
-               }
 
                return true;
        }
@@ -245,14 +242,14 @@ class PostUpdate
                                $default = ['url' => $item['author-link'], 'name' => $item['author-name'],
                                        'photo' => $item['author-avatar'], 'network' => $item['network']];
 
-                               $item['author-id'] = Contact::getIdForURL($item["author-link"], 0, false, $default);
+                               $item['author-id'] = Contact::getIdForURL($item["author-link"], 0, null, $default);
                        }
 
                        if (empty($item['owner-id'])) {
                                $default = ['url' => $item['owner-link'], 'name' => $item['owner-name'],
                                        'photo' => $item['owner-avatar'], 'network' => $item['network']];
 
-                               $item['owner-id'] = Contact::getIdForURL($item["owner-link"], 0, false, $default);
+                               $item['owner-id'] = Contact::getIdForURL($item["owner-link"], 0, null, $default);
                        }
 
                        if (empty($item['psid'])) {
@@ -459,6 +456,11 @@ class PostUpdate
                        return true;
                }
 
+               if (!DBStructure::existsTable('item-delivery-data')) {
+                       DI::config()->set('system', 'post_update_version', 1297);
+                       return true;
+               }
+
                $max_item_delivery_data = DBA::selectFirst('item-delivery-data', ['iid'], ['queue_count > 0 OR queue_done > 0'], ['order' => ['iid']]);
                $max_iid = $max_item_delivery_data['iid'];
 
@@ -703,6 +705,11 @@ class PostUpdate
                        return true;
                }
 
+               if (!DBStructure::existsTable('item-delivery-data')) {
+                       DI::config()->set('system', 'post_update_version', 1345);
+                       return true;
+               }
+
                $id = DI::config()->get('system', 'post_update_version_1345_id', 0);
 
                Logger::info('Start', ['item' => $id]);
@@ -893,7 +900,7 @@ class PostUpdate
        }
 
        /**
-        * update the "gsid" (global server id) field in the contact table 
+        * update the "gsid" (global server id) field in the contact table
         *
         * @return bool "true" when the job is done
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
@@ -925,7 +932,7 @@ class PostUpdate
                        $id = $contact['id'];
 
                        DBA::update('contact',
-                               ['gsid' => GServer::getID($contact['baseurl']), 'baseurl' => GServer::cleanURL($contact['baseurl'])],
+                               ['gsid' => GServer::getID($contact['baseurl'], true), 'baseurl' => GServer::cleanURL($contact['baseurl'])],
                                ['id' => $contact['id']]);
 
                        ++$rows;
@@ -946,7 +953,7 @@ class PostUpdate
        }
 
        /**
-        * update the "gsid" (global server id) field in the apcontact table 
+        * update the "gsid" (global server id) field in the apcontact table
         *
         * @return bool "true" when the job is done
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
@@ -959,7 +966,7 @@ class PostUpdate
                        return true;
                }
 
-               $id = DI::config()->get("system", "post_update_version_1349_id", 0);
+               $id = DI::config()->get("system", "post_update_version_1349_id", '');
 
                Logger::info('Start', ['apcontact' => $id]);
 
@@ -978,7 +985,7 @@ class PostUpdate
                        $id = $apcontact['url'];
 
                        DBA::update('apcontact',
-                               ['gsid' => GServer::getID($apcontact['baseurl']), 'baseurl' => GServer::cleanURL($apcontact['baseurl'])],
+                               ['gsid' => GServer::getID($apcontact['baseurl'], true), 'baseurl' => GServer::cleanURL($apcontact['baseurl'])],
                                ['url' => $apcontact['url']]);
 
                        ++$rows;
@@ -997,57 +1004,4 @@ class PostUpdate
 
                return false;
        }
-
-       /**
-        * update the "gsid" (global server id) field in the gcontact table 
-        *
-        * @return bool "true" when the job is done
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
-        * @throws \ImagickException
-        */
-       private static function update1350()
-       {
-               // Was the script completed?
-               if (DI::config()->get("system", "post_update_version") >= 1350) {
-                       return true;
-               }
-
-               $id = DI::config()->get("system", "post_update_version_1350_id", 0);
-
-               Logger::info('Start', ['gcontact' => $id]);
-
-               $start_id = $id;
-               $rows = 0;
-               $condition = ["`id` > ? AND `gsid` IS NULL AND `server_url` != '' AND NOT `server_url` IS NULL", $id];
-               $params = ['order' => ['id'], 'limit' => 10000];
-               $gcontacts = DBA::select('gcontact', ['id', 'server_url'], $condition, $params);
-
-               if (DBA::errorNo() != 0) {
-                       Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
-                       return false;
-               }
-
-               while ($gcontact = DBA::fetch($gcontacts)) {
-                       $id = $gcontact['id'];
-
-                       DBA::update('gcontact',
-                               ['gsid' => GServer::getID($gcontact['server_url']), 'server_url' => GServer::cleanURL($gcontact['server_url'])],
-                               ['id' => $gcontact['id']]);
-
-                       ++$rows;
-               }
-               DBA::close($gcontacts);
-
-               DI::config()->set("system", "post_update_version_1350_id", $id);
-
-               Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
-
-               if ($start_id == $id) {
-                       DI::config()->set("system", "post_update_version", 1350);
-                       Logger::info('Done');
-                       return true;
-               }
-
-               return false;
-       }
 }