]> git.mxchange.org Git - friendica.git/commitdiff
Replace PostUpdate key-value config entries with key-value pair entries
authorPhilipp <admin@philipp.info>
Thu, 29 Dec 2022 19:18:13 +0000 (20:18 +0100)
committerPhilipp <admin@philipp.info>
Thu, 29 Dec 2022 20:53:56 +0000 (21:53 +0100)
src/Console/AutomaticInstallation.php
src/Console/Config.php
src/Console/Maintenance.php
src/Console/PostUpdate.php
src/Core/Update.php
src/DI.php
src/Database/DBStructure.php
src/Database/PostUpdate.php
src/Model/Contact.php
src/Module/Friendica.php
update.php

index 1a6d10c241a8f89afa79a72a4adc92878a4b47cd..85cfa710c8600b0b1647cc7f0a0995c5ed78d25e 100644 (file)
@@ -100,12 +100,12 @@ Examples
 HELP;
        }
 
-       public function __construct(App\Mode $appMode, Cache $configCache, IManageConfigValues $config, Database $dba, array $argv = null)
+       public function __construct(App\Mode $appMode, Cache $keyValueCache, IManageConfigValues $config, Database $dba, array $argv = null)
        {
                parent::__construct($argv);
 
                $this->appMode     = $appMode;
-               $this->configCache = $configCache;
+               $this->configCache = $keyValueCache;
                $this->config      = $config;
                $this->dba         = $dba;
        }
index 760b1ca51b39822b1a67da3e103c2c30984e3459..1e88d36a8b7388e3e62607c822d0e5755c136fa1 100644 (file)
@@ -94,12 +94,12 @@ HELP;
                return $help;
        }
 
-       public function __construct(App\Mode $appMode, IManageConfigValues $config, array $argv = null)
+       public function __construct(App\Mode $appMode, IManageConfigValues $keyValue, array $argv = null)
        {
                parent::__construct($argv);
 
                $this->appMode = $appMode;
-               $this->config = $config;
+               $this->config = $keyValue;
        }
 
        protected function doExecute(): int
index 7744c9ee471d0b56ed07ea4ab25825a20e86fbc9..e9909ed0572c9bc9f32398da5d17954a3cfb29bf 100644 (file)
@@ -69,12 +69,12 @@ HELP;
                return $help;
        }
 
-       public function __construct(App\Mode $appMode, IManageConfigValues $config, $argv = null)
+       public function __construct(App\Mode $appMode, IManageConfigValues $keyValue, $argv = null)
        {
                parent::__construct($argv);
 
                $this->appMode = $appMode;
-               $this->config = $config;
+               $this->config = $keyValue;
        }
 
        protected function doExecute(): int
index 8bec14e2767030846980b9759cd1e3e99da545b1..cf15fe3e393e15a0faa85c5c9a9e0067163ace0d 100644 (file)
@@ -22,7 +22,7 @@
 namespace Friendica\Console;
 
 use Friendica\App;
-use Friendica\Core\Config\Capability\IManageConfigValues;
+use Friendica\Core\KeyValueStorage\Capabilities\ICanManageKeyValuePairs;
 use Friendica\Core\L10n;
 use Friendica\Core\Update;
 
@@ -38,9 +38,9 @@ class PostUpdate extends \Asika\SimpleConsole\Console
         */
        private $appMode;
        /**
-        * @var IManageConfigValues
+        * @var ICanManageKeyValuePairs
         */
-       private $config;
+       private $keyValue;
        /**
         * @var L10n
         */
@@ -60,13 +60,13 @@ HELP;
                return $help;
        }
 
-       public function __construct(App\Mode $appMode, IManageConfigValues $config, L10n $l10n, array $argv = null)
+       public function __construct(App\Mode $appMode, ICanManageKeyValuePairs $keyValue, L10n $l10n, array $argv = null)
        {
                parent::__construct($argv);
 
-               $this->appMode = $appMode;
-               $this->config = $config;
-               $this->l10n = $l10n;
+               $this->appMode  = $appMode;
+               $this->keyValue = $keyValue;
+               $this->l10n     = $l10n;
        }
 
        protected function doExecute(): int
@@ -83,7 +83,7 @@ HELP;
                        $this->out($this->getHelp());
                        return 0;
                } elseif ($reset_version) {
-                       $this->config->set('system', 'post_update_version', $reset_version);
+                       $this->keyValue->set('post_update_version', $reset_version);
                        echo $this->l10n->t('Post update version number has been set to %s.', $reset_version) . "\n";
                        return 0;
                }
index 8ec96dc9893662d68216900712c29ad015e3cd78..9e05c1b5bcbb5037c1da0660a376c091f5a04c1e 100644 (file)
@@ -76,7 +76,7 @@ class Update
                }
 
                // The postupdate has to completed version 1288 for the new post views to take over
-               $postupdate = DI::config()->get('system', 'post_update_version', self::NEW_TABLE_STRUCTURE_VERSION);
+               $postupdate = DI::keyValue()->get('post_update_version') ?? self::NEW_TABLE_STRUCTURE_VERSION;
                if ($postupdate < self::NEW_TABLE_STRUCTURE_VERSION) {
                        $error = DI::l10n()->t('Updates from postupdate version %s are not supported. Please update at least to version 2021.01 and wait until the postupdate finished version 1383.', $postupdate);
                        if (DI::mode()->getExecutor() == Mode::INDEX) {
index 31f2511d4bf0c3b5f20df81a1abdb36755587093..a430b0daa28f7be445ed12bc212d18bfddc00e17 100644 (file)
@@ -22,7 +22,6 @@
 namespace Friendica;
 
 use Dice\Dice;
-use Friendica\Core\KeyValueStorage\Capabilities\ICanManageKeyValuePairs;
 use Friendica\Core\Session\Capability\IHandleSessions;
 use Friendica\Core\Session\Capability\IHandleUserSessions;
 use Friendica\Navigation\SystemMessages;
@@ -182,7 +181,7 @@ abstract class DI
                return self::$dice->create(Core\Config\Capability\IManageConfigValues::class);
        }
 
-       public static function keyValue(): ICanManageKeyValuePairs
+       public static function keyValue(): Core\KeyValueStorage\Capabilities\ICanManageKeyValuePairs
        {
                return self::$dice->create(Core\KeyValueStorage\Capabilities\ICanManageKeyValuePairs::class);
        }
index cdb5d4ef987f5ea0620fdcae7056724fa656f0df..83e238394ec20b1a59d18936b6a1b900bb42292c 100644 (file)
@@ -53,7 +53,7 @@ class DBStructure
                        throw new \Asika\SimpleConsole\CommandArgsException('The version number must be numeric');
                }
 
-               DI::config()->set('system', 'build', $version);
+               DI::keyValue()->set( 'build',  $version);
                echo DI::l10n()->t('The database version had been set to %s.', $version);
        }
 
@@ -65,7 +65,7 @@ class DBStructure
         */
        public static function dropTables(bool $execute)
        {
-               $postupdate = DI::config()->get('system', 'post_update_version', PostUpdate::VERSION);
+               $postupdate = DI::keyValue()->get('post_update_version') ?? PostUpdate::VERSION;
                if ($postupdate < PostUpdate::VERSION) {
                        echo DI::l10n()->t('The post update is at version %d, it has to be at %d to safely drop the tables.', $postupdate, PostUpdate::VERSION);
                        return;
@@ -176,14 +176,14 @@ class DBStructure
        public static function performUpdate(bool $enable_maintenance_mode = true, bool $verbose = false): string
        {
                if ($enable_maintenance_mode) {
-                       DI::config()->set('system', 'maintenance', 1);
+                       DI::keyValue()->set( 'maintenance',  1);
                }
 
                $status = self::update($verbose, true);
 
                if ($enable_maintenance_mode) {
-                       DI::config()->set('system', 'maintenance', 0);
-                       DI::config()->set('system', 'maintenance_reason', '');
+                       DI::keyValue()->set( 'maintenance',  0);
+                       DI::keyValue()->set( 'maintenance_reason',  '');
                }
 
                return $status;
@@ -213,7 +213,7 @@ class DBStructure
         */
        private static function update(bool $verbose, bool $action, bool $install = false, array $tables = null, array $definition = null): string
        {
-               $in_maintenance_mode = DI::config()->get('system', 'maintenance');
+               $in_maintenance_mode = DI::keyValue()->get('system',  'maintenance');
 
                if ($action && !$install && self::isUpdating()) {
                        return DI::l10n()->t('Another database update is currently running.');
@@ -494,9 +494,9 @@ class DBStructure
 
                if ($action && !$install) {
                        if ($errors) {
-                               DI::config()->set('system', 'dbupdate', self::UPDATE_FAILED);
+                               DI::config()->set('system',  'dbupdate',  self::UPDATE_FAILED);
                        } else {
-                               DI::config()->set('system', 'dbupdate', self::UPDATE_SUCCESSFUL);
+                               DI::config()->set( 'system', 'dbupdate',  self::UPDATE_SUCCESSFUL);
                        }
                }
 
index e57d92ceb738104e251276dd0b4cd0404bf3ac4c..d54c3f2217c726f2c099cc0006dbfb1a593a5a8c 100644 (file)
@@ -129,12 +129,12 @@ class PostUpdate
        private static function update1297()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1297) {
+               if (DI::keyValue()->get('post_update_version') >= 1297) {
                        return true;
                }
 
                if (!DBStructure::existsTable('item-delivery-data')) {
-                       DI::config()->set('system', 'post_update_version', 1297);
+                       DI::keyValue()->set('post_update_version', 1297);
                        return true;
                }
 
@@ -154,7 +154,7 @@ class PostUpdate
 
                Logger::info('Processed rows: ' . DBA::affectedRows());
 
-               DI::config()->set('system', 'post_update_version', 1297);
+               DI::keyValue()->set('post_update_version', 1297);
 
                Logger::info('Done');
 
@@ -169,7 +169,7 @@ class PostUpdate
        private static function update1322()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1322) {
+               if (DI::keyValue()->get('post_update_version') >= 1322) {
                        return true;
                }
 
@@ -188,7 +188,7 @@ class PostUpdate
                }
 
                DBA::close($contact);
-               DI::config()->set('system', 'post_update_version', 1322);
+               DI::keyValue()->set('post_update_version', 1322);
 
                Logger::info('Done');
 
@@ -204,16 +204,16 @@ class PostUpdate
        private static function update1329()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1329) {
+               if (DI::keyValue()->get('post_update_version') >= 1329) {
                        return true;
                }
 
                if (!DBStructure::existsTable('item')) {
-                       DI::config()->set('system', 'post_update_version', 1329);
+                       DI::keyValue()->set('post_update_version', 1329);
                        return true;
                }
 
-               $id = DI::config()->get('system', 'post_update_version_1329_id', 0);
+               $id = DI::keyValue()->get('post_update_version_1329_id') ?? 0;
 
                Logger::info('Start', ['item' => $id]);
 
@@ -237,12 +237,12 @@ class PostUpdate
                }
                DBA::close($items);
 
-               DI::config()->set('system', 'post_update_version_1329_id', $id);
+               DI::keyValue()->set('post_update_version_1329_id', $id);
 
                Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
 
                if ($start_id == $id) {
-                       DI::config()->set('system', 'post_update_version', 1329);
+                       DI::keyValue()->set('post_update_version', 1329);
                        Logger::info('Done');
                        return true;
                }
@@ -259,16 +259,16 @@ class PostUpdate
        private static function update1341()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1341) {
+               if (DI::keyValue()->get('post_update_version') >= 1341) {
                        return true;
                }
 
                if (!DBStructure::existsTable('item-content')) {
-                       DI::config()->set('system', 'post_update_version', 1342);
+                       DI::keyValue()->set('post_update_version', 1342);
                        return true;
                }
 
-               $id = DI::config()->get('system', 'post_update_version_1341_id', 0);
+               $id = DI::keyValue()->get('post_update_version_1341_id') ?? 0;
 
                Logger::info('Start', ['item' => $id]);
 
@@ -288,19 +288,19 @@ class PostUpdate
                        $id = $item['uri-id'];
                        ++$rows;
                        if ($rows % 1000 == 0) {
-                               DI::config()->set('system', 'post_update_version_1341_id', $id);
+                               DI::keyValue()->set('post_update_version_1341_id', $id);
                        }
                }
                DBA::close($items);
 
-               DI::config()->set('system', 'post_update_version_1341_id', $id);
+               DI::keyValue()->set('post_update_version_1341_id', $id);
 
                Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
 
                // When there are less than 1,000 items processed this means that we reached the end
                // The other entries will then be processed with the regular functionality
                if ($rows < 1000) {
-                       DI::config()->set('system', 'post_update_version', 1341);
+                       DI::keyValue()->set('post_update_version', 1341);
                        Logger::info('Done');
                        return true;
                }
@@ -317,16 +317,16 @@ class PostUpdate
        private static function update1342()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1342) {
+               if (DI::keyValue()->get('post_update_version') >= 1342) {
                        return true;
                }
 
                if (!DBStructure::existsTable('term') || !DBStructure::existsTable('item-content')) {
-                       DI::config()->set('system', 'post_update_version', 1342);
+                       DI::keyValue()->set('post_update_version', 1342);
                        return true;
                }
 
-               $id = DI::config()->get('system', 'post_update_version_1342_id', 0);
+               $id = DI::keyValue()->get('post_update_version_1342_id') ?? 0;
 
                Logger::info('Start', ['item' => $id]);
 
@@ -364,19 +364,19 @@ class PostUpdate
                        $id = $term['tid'];
                        ++$rows;
                        if ($rows % 1000 == 0) {
-                               DI::config()->set('system', 'post_update_version_1342_id', $id);
+                               DI::keyValue()->set('post_update_version_1342_id', $id);
                        }
                }
                DBA::close($terms);
 
-               DI::config()->set('system', 'post_update_version_1342_id', $id);
+               DI::keyValue()->set('post_update_version_1342_id', $id);
 
                Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
 
                // When there are less than 1,000 items processed this means that we reached the end
                // The other entries will then be processed with the regular functionality
                if ($rows < 1000) {
-                       DI::config()->set('system', 'post_update_version', 1342);
+                       DI::keyValue()->set('post_update_version', 1342);
                        Logger::info('Done');
                        return true;
                }
@@ -393,16 +393,16 @@ class PostUpdate
        private static function update1345()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1345) {
+               if (DI::keyValue()->get('post_update_version') >= 1345) {
                        return true;
                }
 
                if (!DBStructure::existsTable('item-delivery-data')) {
-                       DI::config()->set('system', 'post_update_version', 1345);
+                       DI::keyValue()->set('post_update_version', 1345);
                        return true;
                }
 
-               $id = DI::config()->get('system', 'post_update_version_1345_id', 0);
+               $id = DI::keyValue()->get('post_update_version_1345_id') ?? 0;
 
                Logger::info('Start', ['item' => $id]);
 
@@ -427,14 +427,14 @@ class PostUpdate
                }
                DBA::close($deliveries);
 
-               DI::config()->set('system', 'post_update_version_1345_id', $id);
+               DI::keyValue()->set('post_update_version_1345_id', $id);
 
                Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
 
                // When there are less than 100 items processed this means that we reached the end
                // The other entries will then be processed with the regular functionality
                if ($rows < 100) {
-                       DI::config()->set('system', 'post_update_version', 1345);
+                       DI::keyValue()->set('post_update_version', 1345);
                        Logger::info('Done');
                        return true;
                }
@@ -476,16 +476,16 @@ class PostUpdate
        private static function update1346()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1346) {
+               if (DI::keyValue()->get('post_update_version') >= 1346) {
                        return true;
                }
 
                if (!DBStructure::existsTable('term')) {
-                       DI::config()->set('system', 'post_update_version', 1346);
+                       DI::keyValue()->set('post_update_version', 1346);
                        return true;
                }
 
-               $id = DI::config()->get('system', 'post_update_version_1346_id', 0);
+               $id = DI::keyValue()->get('post_update_version_1346_id') ?? 0;
 
                Logger::info('Start', ['item' => $id]);
 
@@ -514,19 +514,19 @@ class PostUpdate
                        $id = $term['oid'];
                        ++$rows;
                        if ($rows % 100 == 0) {
-                               DI::config()->set('system', 'post_update_version_1346_id', $id);
+                               DI::keyValue()->set('post_update_version_1346_id', $id);
                        }
                }
                DBA::close($terms);
 
-               DI::config()->set('system', 'post_update_version_1346_id', $id);
+               DI::keyValue()->set('post_update_version_1346_id', $id);
 
                Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
 
                // When there are less than 10 items processed this means that we reached the end
                // The other entries will then be processed with the regular functionality
                if ($rows < 10) {
-                       DI::config()->set('system', 'post_update_version', 1346);
+                       DI::keyValue()->set('post_update_version', 1346);
                        Logger::info('Done');
                        return true;
                }
@@ -544,16 +544,16 @@ class PostUpdate
        private static function update1347()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1347) {
+               if (DI::keyValue()->get('post_update_version') >= 1347) {
                        return true;
                }
 
                if (!DBStructure::existsTable('item-activity') || !DBStructure::existsTable('item')) {
-                       DI::config()->set('system', 'post_update_version', 1347);
+                       DI::keyValue()->set('post_update_version', 1347);
                        return true;
                }
 
-               $id = DI::config()->get('system', 'post_update_version_1347_id', 0);
+               $id = DI::keyValue()->get('post_update_version_1347_id') ?? 0;
 
                Logger::info('Start', ['item' => $id]);
 
@@ -588,12 +588,12 @@ class PostUpdate
                }
                DBA::close($items);
 
-               DI::config()->set('system', 'post_update_version_1347_id', $id);
+               DI::keyValue()->set('post_update_version_1347_id', $id);
 
                Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
 
                if ($start_id == $id) {
-                       DI::config()->set('system', 'post_update_version', 1347);
+                       DI::keyValue()->set('post_update_version', 1347);
                        Logger::info('Done');
                        return true;
                }
@@ -611,11 +611,11 @@ class PostUpdate
        private static function update1348()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1348) {
+               if (DI::keyValue()->get('post_update_version') >= 1348) {
                        return true;
                }
 
-               $id = DI::config()->get('system', 'post_update_version_1348_id', 0);
+               $id = DI::keyValue()->get('post_update_version_1348_id') ?? 0;
 
                Logger::info('Start', ['contact' => $id]);
 
@@ -641,12 +641,12 @@ class PostUpdate
                }
                DBA::close($contacts);
 
-               DI::config()->set('system', 'post_update_version_1348_id', $id);
+               DI::keyValue()->set('post_update_version_1348_id', $id);
 
                Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
 
                if ($start_id == $id) {
-                       DI::config()->set('system', 'post_update_version', 1348);
+                       DI::keyValue()->set('post_update_version', 1348);
                        Logger::info('Done');
                        return true;
                }
@@ -664,11 +664,11 @@ class PostUpdate
        private static function update1349()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1349) {
+               if (DI::keyValue()->get('post_update_version') >= 1349) {
                        return true;
                }
 
-               $id = DI::config()->get('system', 'post_update_version_1349_id', '');
+               $id = DI::keyValue()->get('post_update_version_1349_id') ?? '';
 
                Logger::info('Start', ['apcontact' => $id]);
 
@@ -694,12 +694,12 @@ class PostUpdate
                }
                DBA::close($apcontacts);
 
-               DI::config()->set('system', 'post_update_version_1349_id', $id);
+               DI::keyValue()->set('post_update_version_1349_id', $id);
 
                Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
 
                if ($start_id == $id) {
-                       DI::config()->set('system', 'post_update_version', 1349);
+                       DI::keyValue()->set('post_update_version', 1349);
                        Logger::info('Done');
                        return true;
                }
@@ -717,7 +717,7 @@ class PostUpdate
        private static function update1383()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1383) {
+               if (DI::keyValue()->get('post_update_version') >= 1383) {
                        return true;
                }
 
@@ -743,7 +743,7 @@ class PostUpdate
                }
                DBA::close($photos);
 
-               DI::config()->set('system', 'post_update_version', 1383);
+               DI::keyValue()->set('post_update_version', 1383);
                Logger::info('Done', ['deleted' => $deleted]);
                return true;
        }
@@ -758,7 +758,7 @@ class PostUpdate
        private static function update1384()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1384) {
+               if (DI::keyValue()->get('post_update_version') >= 1384) {
                        return true;
                }
 
@@ -788,7 +788,7 @@ class PostUpdate
                Logger::info('Processed', ['rows' => $rows]);
 
                if ($rows <= 100) {
-                       DI::config()->set('system', 'post_update_version', 1384);
+                       DI::keyValue()->set('post_update_version', 1384);
                        Logger::info('Done');
                        return true;
                }
@@ -806,12 +806,12 @@ class PostUpdate
        private static function update1400()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1400) {
+               if (DI::keyValue()->get('post_update_version') >= 1400) {
                        return true;
                }
 
                if (!DBStructure::existsTable('item')) {
-                       DI::config()->set('system', 'post_update_version', 1400);
+                       DI::keyValue()->set('post_update_version', 1400);
                        return true;
                }
 
@@ -835,7 +835,7 @@ class PostUpdate
                Logger::info('Processed', ['rows' => $rows]);
 
                if ($rows <= 100) {
-                       DI::config()->set('system', 'post_update_version', 1400);
+                       DI::keyValue()->set('post_update_version', 1400);
                        Logger::info('Done');
                        return true;
                }
@@ -853,7 +853,7 @@ class PostUpdate
        private static function update1424()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1424) {
+               if (DI::keyValue()->get('post_update_version') >= 1424) {
                        return true;
                }
 
@@ -877,7 +877,7 @@ class PostUpdate
                Logger::info('Processed', ['rows' => $rows]);
 
                if ($rows <= 100) {
-                       DI::config()->set('system', 'post_update_version', 1424);
+                       DI::keyValue()->set('post_update_version', 1424);
                        Logger::info('Done');
                        return true;
                }
@@ -895,12 +895,12 @@ class PostUpdate
        private static function update1425()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1425) {
+               if (DI::keyValue()->get('post_update_version') >= 1425) {
                        return true;
                }
 
                if (!DBStructure::existsTable('fcontact')) {
-                       DI::config()->set('system', 'post_update_version', 1425);
+                       DI::keyValue()->set('post_update_version', 1425);
                        return true;
                }
 
@@ -929,7 +929,7 @@ class PostUpdate
                Logger::info('Processed', ['rows' => $rows]);
 
                if ($rows <= 100) {
-                       DI::config()->set('system', 'post_update_version', 1425);
+                       DI::keyValue()->set('post_update_version', 1425);
                        Logger::info('Done');
                        return true;
                }
@@ -947,7 +947,7 @@ class PostUpdate
        private static function update1426()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1426) {
+               if (DI::keyValue()->get('post_update_version') >= 1426) {
                        return true;
                }
 
@@ -976,7 +976,7 @@ class PostUpdate
                Logger::info('Processed', ['rows' => $rows]);
 
                if ($rows <= 100) {
-                       DI::config()->set('system', 'post_update_version', 1426);
+                       DI::keyValue()->set('post_update_version', 1426);
                        Logger::info('Done');
                        return true;
                }
@@ -994,7 +994,7 @@ class PostUpdate
        private static function update1427()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1427) {
+               if (DI::keyValue()->get('post_update_version') >= 1427) {
                        return true;
                }
 
@@ -1023,7 +1023,7 @@ class PostUpdate
                Logger::info('Processed', ['rows' => $rows]);
 
                if ($rows <= 100) {
-                       DI::config()->set('system', 'post_update_version', 1427);
+                       DI::keyValue()->set('post_update_version', 1427);
                        Logger::info('Done');
                        return true;
                }
@@ -1041,16 +1041,16 @@ class PostUpdate
        private static function update1452()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1452) {
+               if (DI::keyValue()->get('post_update_version') >= 1452) {
                        return true;
                }
 
                if (!DBStructure::existsTable('conversation')) {
-                       DI::config()->set('system', 'post_update_version', 1452);
+                       DI::keyValue()->set('post_update_version', 1452);
                        return true;
                }
 
-               $id = DI::config()->get('system', 'post_update_version_1452_id', 0);
+               $id = DI::keyValue()->get('post_update_version_1452_id') ?? 0;
 
                Logger::info('Start', ['uri-id' => $id]);
 
@@ -1089,12 +1089,12 @@ class PostUpdate
 
                DBA::close($conversations);
 
-               DI::config()->set('system', 'post_update_version_1452_id', $id);
+               DI::keyValue()->set('post_update_version_1452_id', $id);
 
                Logger::info('Processed', ['rows' => $rows, 'last' => $id, 'last-received' => $received]);
 
                if ($rows <= 100) {
-                       DI::config()->set('system', 'post_update_version', 1452);
+                       DI::keyValue()->set('post_update_version', 1452);
                        Logger::info('Done');
                        return true;
                }
@@ -1113,7 +1113,7 @@ class PostUpdate
        private static function update1483()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1483) {
+               if (DI::keyValue()->get('post_update_version') >= 1483) {
                        return true;
                }
 
@@ -1129,7 +1129,7 @@ class PostUpdate
                }
                DBA::close($posts);
 
-               DI::config()->set('system', 'post_update_version', 1483);
+               DI::keyValue()->set('post_update_version', 1483);
                Logger::info('Done');
                return true;
        }
@@ -1144,11 +1144,11 @@ class PostUpdate
        private static function update1484()
        {
                // Was the script completed?
-               if (DI::config()->get('system', 'post_update_version') >= 1484) {
+               if (DI::keyValue()->get('post_update_version') >= 1484) {
                        return true;
                }
 
-               $id = DI::config()->get('system', 'post_update_version_1484_id', 0);
+               $id = DI::keyValue()->get('post_update_version_1484_id') ?? 0;
 
                Logger::info('Start', ['id' => $id]);
 
@@ -1172,12 +1172,12 @@ class PostUpdate
                }
                DBA::close($contacts);
 
-               DI::config()->set('system', 'post_update_version_1484_id', $id);
+               DI::keyValue()->set('post_update_version_1484_id', $id);
 
                Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
 
                if ($rows <= 100) {
-                       DI::config()->set('system', 'post_update_version', 1484);
+                       DI::keyValue()->set('post_update_version', 1484);
                        Logger::info('Done');
                        return true;
                }
index bf90edcd4c3e20fd78a60677e653d158b228e7ec..1bf2f17910f882b38719b04cba8ae92adc0865a2 100644 (file)
@@ -624,7 +624,7 @@ class Contact
        public static function getPublicAndUserContactID(int $cid, int $uid): array
        {
                // We have to use the legacy function as long as the post update hasn't finished
-               if (DI::config()->get('system', 'post_update_version') < 1427) {
+               if (DI::keyValue()->get('post_update_version') < 1427) {
                        return self::legacyGetPublicAndUserContactID($cid, $uid);
                }
 
index 37bd69da498102dc3fc4155a4fcfc34902244c03..f21b85fc45672e1f2b232cedee30fe351967fd8d 100644 (file)
@@ -42,6 +42,7 @@ class Friendica extends BaseModule
        protected function content(array $request = []): string
        {
                $config = DI::config();
+               $keyValue = DI::keyValue();
 
                $visibleAddonList = Addon::getVisibleList();
                if (!empty($visibleAddonList)) {
@@ -100,7 +101,7 @@ class Friendica extends BaseModule
                                '<strong>' . App::VERSION . '</strong>',
                                DI::baseUrl()->get(),
                                '<strong>' . $config->get('system', 'build') . '/' . DB_UPDATE_VERSION . '</strong>',
-                               '<strong>' . $config->get('system', 'post_update_version') . '/' . PostUpdate::VERSION . '</strong>'),
+                               '<strong>' . $keyValue->get('post_update_version') . '/' . PostUpdate::VERSION . '</strong>'),
                        'friendica' => DI::l10n()->t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.'),
                        'bugs'      => DI::l10n()->t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">' . DI::l10n()->t('the bugtracker at github') . '</a>',
                        'info'      => DI::l10n()->t('Suggestions, praise, etc. - please email "info" at "friendi - dot - ca'),
index 82f4fba58bc847c106cd72f6a9a5f03434aedfc7..fb62f28df46191053eac105f31a815750398cb0b 100644 (file)
@@ -982,7 +982,7 @@ function update_1429()
                return Update::FAILED;
        }
 
-       DI::config()->set('system', 'post_update_version', 1423);
+       DI::keyValue()->set('post_update_version', 1423);
 
        return Update::SUCCESS;
 }
@@ -1145,3 +1145,14 @@ function update_1502()
        DBA::e("UPDATE `pconfig` SET `cat` = 'calendar' WHERE `k` = 'first_day_of_week'");
        return Update::SUCCESS;
 }
+
+function update_1505()
+{
+       $postUpdateEntries = DBA::selectToArray('config', ['k', 'v'], ["`k` LIKE ?", "post_update_%"]);
+
+       foreach ($postUpdateEntries as $postUpdateEntry) {
+               DI::keyValue()->set($postUpdateEntry['k'], $postUpdateEntry['v']);
+       }
+
+       return DBA::delete('config', ["`k` LIKE ?", "post_update_%"]) ? Update::SUCCESS : Update::FAILED;
+}