X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FUpdate.php;h=a52ef903b2da8867854fc1660317d57817e51cec;hb=fb63274aafa176ee2eff964e809306719e80c847;hp=7cb3212679646bc1dd22af0aa8d4c45fe14343ac;hpb=76414a51691dfffefd4de11fe025e44a9a59586a;p=friendica.git diff --git a/src/Core/Update.php b/src/Core/Update.php index 7cb3212679..a52ef903b2 100644 --- a/src/Core/Update.php +++ b/src/Core/Update.php @@ -3,11 +3,8 @@ namespace Friendica\Core; use Friendica\App; -use Friendica\Core\Config\Cache\IConfigCache; use Friendica\Database\DBA; use Friendica\Database\DBStructure; -use Friendica\Util\Config\ConfigFileLoader; -use Friendica\Util\Config\ConfigFileSaver; use Friendica\Util\Strings; class Update @@ -18,11 +15,13 @@ class Update /** * @brief Function to check if the Database structure needs an update. * - * @param string $basePath The base path of this application - * @param boolean $via_worker boolean Is the check run via the worker? + * @param string $basePath The base path of this application + * @param boolean $via_worker Is the check run via the worker? + * @param App\Mode $mode The current app mode + * * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function check($basePath, $via_worker) + public static function check($basePath, $via_worker, App\Mode $mode) { if (!DBA::connected()) { return; @@ -223,74 +222,6 @@ class Update } } - /** - * Checks the config settings and saves given config values into the config file - * - * @param string $basePath The basepath of Friendica - * @param App\Mode $mode The Application mode - * - * @return bool True, if something has been saved - */ - public static function saveConfigToFile($basePath, App\Mode $mode) - { - $configFileLoader = new ConfigFileLoader($basePath, $mode); - $configCache = new Config\Cache\ConfigCache(); - $configFileLoader->setupCache($configCache); - $configFileSaver = new ConfigFileSaver($basePath); - - $updated = false; - - if (self::updateConfigEntry($configCache, $configFileSaver,'config', 'hostname')) { - $updated = true; - }; - if (self::updateConfigEntry($configCache, $configFileSaver,'system', 'basepath')) { - $updated = true; - } - - if (!$configFileSaver->saveToConfigFile()) { - Logger::alert('Config entry update failed - maybe wrong permission?'); - return false; - } - - DBA::delete('config', ['cat' => 'config', 'k' => 'hostname']); - DBA::delete('config', ['cat' => 'system', 'k' => 'basepath']); - - return $updated; - } - - /** - * Adds a value to the ConfigFileSave in case it isn't already updated - * - * @param IConfigCache $configCache The cached config file - * @param ConfigFileSaver $configFileSaver The config file saver - * @param string $cat The config category - * @param string $key The config key - * - * @return boolean True, if a value was updated - * - * @throws \Exception if DBA or Logger doesn't work - */ - private static function updateConfigEntry(IConfigCache $configCache, ConfigFileSaver $configFileSaver, $cat, $key) - { - // check if the config file differs from the whole configuration (= The db contains other values) - $fileConfig = $configCache->get($cat, $key); - - $savedConfig = DBA::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $key]); - - if (!DBA::isResult($savedConfig)) { - return false; - } - - if ($fileConfig !== $savedConfig['v']) { - Logger::info('Difference in config found', ['cat' => $cat, 'key' => $key, 'file' => $fileConfig, 'saved' => $savedConfig['v']]); - $configFileSaver->addConfigValue($cat, $key, $savedConfig['v']); - } else { - Logger::info('No Difference in config found', ['cat' => $cat, 'key' => $key, 'value' => $fileConfig, 'saved' => $savedConfig['v']]); - } - - return true; - } - /** * send the email and do what is needed to do on update fails * @@ -335,6 +266,7 @@ class Update 'uid' => $admin['uid'], 'type' => SYSTEM_EMAIL, 'to_email' => $admin['email'], + 'subject' => l10n::t('[Friendica Notify] Database update'), 'preamble' => $preamble, 'body' => $body, 'language' => $lang] @@ -373,6 +305,7 @@ class Update 'uid' => $admin['uid'], 'type' => SYSTEM_EMAIL, 'to_email' => $admin['email'], + 'subject' => l10n::t('[Friendica Notify] Database update'), 'preamble' => $preamble, 'body' => $preamble, 'language' => $lang]