Move Config::set() to DI::config()->set()
This commit is contained in:
parent
6c36fd9e01
commit
3411ced833
29 changed files with 213 additions and 229 deletions
|
@ -348,7 +348,7 @@ class Addon
|
|||
*/
|
||||
public static function saveEnabledList()
|
||||
{
|
||||
return Config::set('system', 'addon', implode(',', self::$addons));
|
||||
return DI::config()->set('system', 'addon', implode(',', self::$addons));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,22 +19,6 @@ use Friendica\DI;
|
|||
*/
|
||||
class Config
|
||||
{
|
||||
/**
|
||||
* Stores a config value ($value) in the category ($cat) under the key ($key)
|
||||
*
|
||||
* Note: Please do not store booleans - convert to 0/1 integer values!
|
||||
*
|
||||
* @param string $cat The category of the configuration value
|
||||
* @param string $key The configuration key to set
|
||||
* @param mixed $value The value to store
|
||||
*
|
||||
* @return bool Operation success
|
||||
*/
|
||||
public static function set($cat, $key, $value)
|
||||
{
|
||||
return DI::config()->set($cat, $key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the given key from the system configuration.
|
||||
*
|
||||
|
|
|
@ -36,7 +36,7 @@ class Theme
|
|||
|
||||
public static function setAllowedList(array $allowed_themes)
|
||||
{
|
||||
Config::set('system', 'allowed_themes', implode(',', array_unique($allowed_themes)));
|
||||
DI::config()->set('system', 'allowed_themes', implode(',', array_unique($allowed_themes)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,7 +36,7 @@ class Update
|
|||
$build = DI::config()->get('system', 'build');
|
||||
|
||||
if (empty($build)) {
|
||||
Config::set('system', 'build', DB_UPDATE_VERSION - 1);
|
||||
DI::config()->set('system', 'build', DB_UPDATE_VERSION - 1);
|
||||
$build = DB_UPDATE_VERSION - 1;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class Update
|
|||
|
||||
if (empty($build) || ($build > DB_UPDATE_VERSION)) {
|
||||
$build = DB_UPDATE_VERSION - 1;
|
||||
Config::set('system', 'build', $build);
|
||||
DI::config()->set('system', 'build', $build);
|
||||
}
|
||||
|
||||
if ($build != DB_UPDATE_VERSION || $force) {
|
||||
|
@ -110,7 +110,7 @@ class Update
|
|||
for ($x = $stored + 1; $x <= $current; $x++) {
|
||||
$r = self::runUpdateFunction($x, 'pre_update');
|
||||
if (!$r) {
|
||||
Config::set('system', 'update', Update::FAILED);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
return $r;
|
||||
}
|
||||
|
@ -126,12 +126,12 @@ class Update
|
|||
);
|
||||
}
|
||||
Logger::error('Update ERROR.', ['from' => $stored, 'to' => $current, 'retval' => $retval]);
|
||||
Config::set('system', 'update', Update::FAILED);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
return $retval;
|
||||
} else {
|
||||
Config::set('database', 'last_successful_update', $current);
|
||||
Config::set('database', 'last_successful_update_time', time());
|
||||
DI::config()->set('database', 'last_successful_update', $current);
|
||||
DI::config()->set('database', 'last_successful_update_time', time());
|
||||
Logger::info('Update finished.', ['from' => $stored, 'to' => $current]);
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ class Update
|
|||
for ($x = $stored + 1; $x <= $current; $x++) {
|
||||
$r = self::runUpdateFunction($x, 'update');
|
||||
if (!$r) {
|
||||
Config::set('system', 'update', Update::FAILED);
|
||||
DI::config()->set('system', 'update', Update::FAILED);
|
||||
DI::lock()->release('dbupdate');
|
||||
return $r;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ class Update
|
|||
self::updateSuccessfull($stored, $current);
|
||||
}
|
||||
|
||||
Config::set('system', 'update', Update::SUCCESS);
|
||||
DI::config()->set('system', 'update', Update::SUCCESS);
|
||||
DI::lock()->release('dbupdate');
|
||||
}
|
||||
}
|
||||
|
@ -197,11 +197,11 @@ class Update
|
|||
DI::lock()->release('dbupdate_function');
|
||||
return false;
|
||||
} else {
|
||||
Config::set('database', 'last_successful_update_function', $funcname);
|
||||
Config::set('database', 'last_successful_update_function_time', time());
|
||||
DI::config()->set('database', 'last_successful_update_function', $funcname);
|
||||
DI::config()->set('database', 'last_successful_update_function_time', time());
|
||||
|
||||
if ($prefix == 'update') {
|
||||
Config::set('system', 'build', $x);
|
||||
DI::config()->set('system', 'build', $x);
|
||||
}
|
||||
|
||||
DI::lock()->release('dbupdate_function');
|
||||
|
@ -212,11 +212,11 @@ class Update
|
|||
} else {
|
||||
Logger::info('Update function skipped.', ['function' => $funcname]);
|
||||
|
||||
Config::set('database', 'last_successful_update_function', $funcname);
|
||||
Config::set('database', 'last_successful_update_function_time', time());
|
||||
DI::config()->set('database', 'last_successful_update_function', $funcname);
|
||||
DI::config()->set('database', 'last_successful_update_function_time', time());
|
||||
|
||||
if ($prefix == 'update') {
|
||||
Config::set('system', 'build', $x);
|
||||
DI::config()->set('system', 'build', $x);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -65,7 +65,7 @@ class Worker
|
|||
// Kill stale processes every 5 minutes
|
||||
$last_cleanup = DI::config()->get('system', 'worker_last_cleaned', 0);
|
||||
if (time() > ($last_cleanup + 300)) {
|
||||
Config::set('system', 'worker_last_cleaned', time());
|
||||
DI::config()->set('system', 'worker_last_cleaned', time());
|
||||
self::killStaleWorkers();
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ class Worker
|
|||
$stamp = (float)microtime(true);
|
||||
$condition = ["`id` = ? AND `next_try` < ?", $queue['id'], DateTimeFormat::utcNow()];
|
||||
if (DBA::update('workerqueue', ['done' => true], $condition)) {
|
||||
Config::set('system', 'last_worker_execution', DateTimeFormat::utcNow());
|
||||
DI::config()->set('system', 'last_worker_execution', DateTimeFormat::utcNow());
|
||||
}
|
||||
self::$db_duration = (microtime(true) - $stamp);
|
||||
self::$db_duration_write += (microtime(true) - $stamp);
|
||||
|
@ -343,7 +343,7 @@ class Worker
|
|||
|
||||
$stamp = (float)microtime(true);
|
||||
if (DBA::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
|
||||
Config::set('system', 'last_worker_execution', DateTimeFormat::utcNow());
|
||||
DI::config()->set('system', 'last_worker_execution', DateTimeFormat::utcNow());
|
||||
}
|
||||
self::$db_duration = (microtime(true) - $stamp);
|
||||
self::$db_duration_write += (microtime(true) - $stamp);
|
||||
|
@ -1004,7 +1004,7 @@ class Worker
|
|||
return;
|
||||
}
|
||||
|
||||
Config::set("system", "worker_started", time());
|
||||
DI::config()->set("system", "worker_started", time());
|
||||
|
||||
// Do we have enough running workers? Then we quit here.
|
||||
if (self::tooMuchWorkers()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue