Apply suggestions
This commit is contained in:
@@ -100,7 +100,7 @@ HELP;
|
||||
|
||||
$enabled = intval($this->getArgument(0));
|
||||
|
||||
$transactionConfig = $this->config->transactional();
|
||||
$transactionConfig = $this->config->beginTransaction();
|
||||
|
||||
$transactionConfig->set('system', 'maintenance', $enabled);
|
||||
|
||||
@@ -112,7 +112,7 @@ HELP;
|
||||
$transactionConfig->delete('system', 'maintenance_reason');
|
||||
}
|
||||
|
||||
$transactionConfig->save();
|
||||
$transactionConfig->commit();
|
||||
|
||||
if ($enabled) {
|
||||
$mode_str = "maintenance mode";
|
||||
|
||||
@@ -101,9 +101,10 @@ HELP;
|
||||
$old_host = str_replace('http://', '@', Strings::normaliseLink($old_url));
|
||||
|
||||
$this->out('Entering maintenance mode');
|
||||
$this->config->set('system', 'maintenance', true, false);
|
||||
$this->config->set('system', 'maintenance_reason', 'Relocating node to ' . $new_url, false);
|
||||
|
||||
$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.');
|
||||
@@ -189,10 +190,10 @@ HELP;
|
||||
return 1;
|
||||
} finally {
|
||||
$this->out('Leaving maintenance mode');
|
||||
$this->config->transactional()
|
||||
$this->config->beginTransaction()
|
||||
->set('system', 'maintenance', false)
|
||||
->delete('system', 'maintenance_reason')
|
||||
->save();
|
||||
->commit();
|
||||
}
|
||||
|
||||
// send relocate
|
||||
|
||||
@@ -94,9 +94,9 @@ interface IManageConfigValues
|
||||
*
|
||||
* It relies on the current instance, so after save(), the values of this config class will get altered at once too.
|
||||
*
|
||||
* @return ISetConfigValuesTransactional
|
||||
* @return ISetConfigValuesTransactionally
|
||||
*/
|
||||
public function transactional(): ISetConfigValuesTransactional;
|
||||
public function beginTransaction(): ISetConfigValuesTransactionally;
|
||||
|
||||
/**
|
||||
* Deletes the given key from the system configuration.
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ use Friendica\Core\Config\Exception\ConfigPersistenceException;
|
||||
* Interface for transactional saving of config values
|
||||
* It buffers every set/delete until "save()" is called
|
||||
*/
|
||||
interface ISetConfigValuesTransactional
|
||||
interface ISetConfigValuesTransactionally
|
||||
{
|
||||
/**
|
||||
* Get a particular user's config variable given the category name
|
||||
@@ -76,9 +76,9 @@ interface ISetConfigValuesTransactional
|
||||
public function delete(string $cat, string $key): self;
|
||||
|
||||
/**
|
||||
* Saves the node specific config values
|
||||
* Commits the changes of the current transaction
|
||||
*
|
||||
* @throws ConfigPersistenceException In case the persistence layer throws errors
|
||||
*/
|
||||
public function save(): void;
|
||||
public function commit(): void;
|
||||
}
|
||||
@@ -22,7 +22,7 @@
|
||||
namespace Friendica\Core\Config\Model;
|
||||
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Config\Capability\ISetConfigValuesTransactional;
|
||||
use Friendica\Core\Config\Capability\ISetConfigValuesTransactionally;
|
||||
use Friendica\Core\Config\Exception\ConfigFileException;
|
||||
use Friendica\Core\Config\Exception\ConfigPersistenceException;
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
@@ -63,9 +63,9 @@ class Config implements IManageConfigValues
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function transactional(): ISetConfigValuesTransactional
|
||||
public function beginTransaction(): ISetConfigValuesTransactionally
|
||||
{
|
||||
return new TransactionalConfig($this);
|
||||
return new ConfigTransaction($this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-6
@@ -22,14 +22,14 @@
|
||||
namespace Friendica\Core\Config\Model;
|
||||
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Config\Capability\ISetConfigValuesTransactional;
|
||||
use Friendica\Core\Config\Capability\ISetConfigValuesTransactionally;
|
||||
use Friendica\Core\Config\Exception\ConfigPersistenceException;
|
||||
use Friendica\Core\Config\ValueObject\Cache;
|
||||
|
||||
/**
|
||||
* config class, which sets values into a temporary buffer until "save()" is called
|
||||
* Transaction class for configurations, which sets values into a temporary buffer until "save()" is called
|
||||
*/
|
||||
class TransactionalConfig implements ISetConfigValuesTransactional
|
||||
class ConfigTransaction implements ISetConfigValuesTransactionally
|
||||
{
|
||||
/** @var IManageConfigValues */
|
||||
protected $config;
|
||||
@@ -54,7 +54,7 @@ class TransactionalConfig implements ISetConfigValuesTransactional
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function set(string $cat, string $key, $value): ISetConfigValuesTransactional
|
||||
public function set(string $cat, string $key, $value): ISetConfigValuesTransactionally
|
||||
{
|
||||
$this->cache->set($cat, $key, $value, Cache::SOURCE_DATA);
|
||||
|
||||
@@ -63,7 +63,7 @@ class TransactionalConfig implements ISetConfigValuesTransactional
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function delete(string $cat, string $key): ISetConfigValuesTransactional
|
||||
public function delete(string $cat, string $key): ISetConfigValuesTransactionally
|
||||
{
|
||||
$this->cache->delete($cat, $key);
|
||||
$this->delCache->set($cat, $key, 'deleted');
|
||||
@@ -72,7 +72,7 @@ class TransactionalConfig implements ISetConfigValuesTransactional
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function save(): void
|
||||
public function commit(): void
|
||||
{
|
||||
try {
|
||||
$newCache = $this->config->getCache()->merge($this->cache);
|
||||
@@ -332,10 +332,8 @@ class Cache
|
||||
$keys = array_keys($cache->config[$category]);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (!is_null($newConfig[$category][$key] ?? null)) {
|
||||
unset($newConfig[$category][$key]);
|
||||
unset($newSource[$category][$key]);
|
||||
}
|
||||
unset($newConfig[$category][$key]);
|
||||
unset($newSource[$category][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -160,10 +160,10 @@ class Update
|
||||
Logger::warning('Pre update failed', ['version' => $version]);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
DI::config()->transactional()
|
||||
DI::config()->beginTransaction()
|
||||
->set('system', 'maintenance', false)
|
||||
->delete('system', 'maintenance_reason')
|
||||
->save();
|
||||
->commit();
|
||||
return $r;
|
||||
} else {
|
||||
Logger::notice('Pre update executed.', ['version' => $version]);
|
||||
@@ -183,10 +183,10 @@ class Update
|
||||
Logger::error('Update ERROR.', ['from' => $stored, 'to' => $current, 'retval' => $retval]);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
DI::config()->transactional()
|
||||
DI::config()->beginTransaction()
|
||||
->set('system', 'maintenance', false)
|
||||
->delete('system', 'maintenance_reason')
|
||||
->save();
|
||||
->commit();
|
||||
return $retval;
|
||||
} else {
|
||||
Logger::notice('Database structure update finished.', ['from' => $stored, 'to' => $current]);
|
||||
@@ -202,10 +202,10 @@ class Update
|
||||
Logger::warning('Post update failed', ['version' => $version]);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
DI::config()->transactional()
|
||||
DI::config()->beginTransaction()
|
||||
->set('system', 'maintenance', false)
|
||||
->delete('system', 'maintenance_reason')
|
||||
->save();
|
||||
->commit();
|
||||
return $r;
|
||||
} else {
|
||||
DI::config()->set('system', 'build', $version);
|
||||
@@ -216,10 +216,10 @@ class Update
|
||||
DI::config()->set('system', 'build', $current);
|
||||
DI::config()->set('system', 'update', Update::SUCCESS);
|
||||
DI::lock()->release('dbupdate');
|
||||
DI::config()->transactional()
|
||||
DI::config()->beginTransaction()
|
||||
->set('system', 'maintenance', false)
|
||||
->delete('system', 'maintenance_reason')
|
||||
->save();
|
||||
->commit();
|
||||
|
||||
Logger::notice('Update success.', ['from' => $stored, 'to' => $current]);
|
||||
if ($sendMail) {
|
||||
|
||||
@@ -182,10 +182,10 @@ class DBStructure
|
||||
$status = self::update($verbose, true);
|
||||
|
||||
if ($enable_maintenance_mode) {
|
||||
DI::config()->transactional()
|
||||
DI::config()->beginTransaction()
|
||||
->set('system', 'maintenance', false)
|
||||
->delete('system', 'maintenance_reason')
|
||||
->save();
|
||||
->commit();
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
||||
@@ -144,7 +144,7 @@ class Site extends BaseAdmin
|
||||
$relay_user_tags = !empty($_POST['relay_user_tags']);
|
||||
$active_panel = (!empty($_POST['active_panel']) ? "#" . trim($_POST['active_panel']) : '');
|
||||
|
||||
$transactionConfig = DI::config()->transactional();
|
||||
$transactionConfig = DI::config()->beginTransaction();
|
||||
|
||||
// Has the directory url changed? If yes, then resubmit the existing profiles there
|
||||
if ($global_directory != DI::config()->get('system', 'directory') && ($global_directory != '')) {
|
||||
@@ -320,7 +320,7 @@ class Site extends BaseAdmin
|
||||
$transactionConfig->set('system', 'relay_deny_tags' , $relay_deny_tags);
|
||||
$transactionConfig->set('system', 'relay_user_tags' , $relay_user_tags);
|
||||
|
||||
$transactionConfig->save();
|
||||
$transactionConfig->commit();
|
||||
|
||||
DI::baseUrl()->redirect('admin/site' . $active_panel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user