]> git.mxchange.org Git - friendica.git/blobdiff - src/Console/Relocate.php
spelling: unable
[friendica.git] / src / Console / Relocate.php
index c1db6ef534c604f42f70c07c11522b67b48418ac..a6fdd8bfbd1304a0ecff34e1656236fd04b6334e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -24,8 +24,8 @@ namespace Friendica\Console;
 use Asika\SimpleConsole\Console;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\Worker;
+use Friendica\Protocol\Delivery;
 use Friendica\Util\Strings;
-use Friendica\Worker\Delivery;
 
 class Relocate extends Console
 {
@@ -92,18 +92,19 @@ HELP;
                        throw new \InvalidArgumentException('Can not parse new base URL. Must have at least <scheme>://<domain>');
                }
 
-               $this->out(sprintf('Relocation started from %s to %s. Could take a while to complete.', $this->baseUrl->get(true), $this->getArgument(0)));
+               $this->out(sprintf('Relocation started from %s to %s. Could take a while to complete.', $this->baseUrl, $this->getArgument(0)));
 
-               $old_url = $this->baseUrl->get(true);
+               $old_url = $this->baseUrl;
 
                // Generate host names for relocation the addresses in the format user@address.tld
                $new_host = str_replace('http://', '@', Strings::normaliseLink($new_url));
                $old_host = str_replace('http://', '@', Strings::normaliseLink($old_url));
 
                $this->out('Entering maintenance mode');
-               $this->config->set('system', 'maintenance', true);
-               $this->config->set('system', 'maintenance_reason', 'Relocating node to ' . $new_url);
-
+               $this->config->beginTransaction()
+                                        ->set('system', 'maintenance', true)
+                                        ->set('system', 'maintenance_reason', 'Relocating node to ' . $new_url)
+                                        ->commit();
                try {
                        if (!$this->database->transaction()) {
                                throw new \Exception('Unable to start a transaction, please retry later.');
@@ -131,9 +132,9 @@ HELP;
                        $this->out('Updating event table fields');
                        $this->database->replaceInTableFields('event', ['uri'], $old_url, $new_url);
 
-                       $this->out('Updating fcontact table fields');
-                       $this->database->replaceInTableFields('fcontact', ['url', 'photo', 'request', 'batch', 'poll', 'confirm', 'alias'], $old_url, $new_url);
-                       $this->database->replaceInTableFields('fcontact', ['addr'], $old_host, $new_host);
+                       $this->out('Updating diaspora-contact table fields');
+                       $this->database->replaceInTableFields('diaspora-contact', ['alias', 'photo', 'photo-medium', 'photo-small', 'batch', 'notify', 'poll', 'subscribe'], $old_url, $new_url);
+                       $this->database->replaceInTableFields('diaspora-contact', ['addr'], $old_host, $new_host);
 
                        $this->out('Updating fsuggest table fields');
                        $this->database->replaceInTableFields('fsuggest', ['url', 'request', 'photo'], $old_url, $new_url);
@@ -178,7 +179,6 @@ HELP;
                        // update config
                        $this->out('Updating config values');
                        $this->config->set('system', 'url', $new_url);
-                       $this->baseUrl->saveByURL($new_url);
 
                        $this->database->commit();
                } catch (\Throwable $e) {
@@ -189,15 +189,17 @@ HELP;
                        return 1;
                } finally {
                        $this->out('Leaving maintenance mode');
-                       $this->config->set('system', 'maintenance', false);
-                       $this->config->set('system', 'maintenance_reason', '');
+                       $this->config->beginTransaction()
+                                                ->set('system', 'maintenance', false)
+                                                ->delete('system', 'maintenance_reason')
+                                                ->commit();
                }
 
                // send relocate
                $this->out('Schedule relocation messages to remote Friendica and Diaspora hosts');
                $users = $this->database->selectToArray('user', ['uid'], ['account_removed' => false, 'account_expired' => false]);
                foreach ($users as $user) {
-                       Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $user['uid']);
+                       Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $user['uid']);
                }
 
                return 0;