<?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
*
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
{
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 = (string)$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.');
$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);
// 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) {
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