From 1ed67fba3d0e33d10bf6112a15b9e086a6a5ee89 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 29 Dec 2022 20:51:04 +0100 Subject: [PATCH] Replace addon "last" config entries with key-value entries --- src/Model/GServer.php | 4 ++-- update.php | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Model/GServer.php b/src/Model/GServer.php index b0a9dd5c9..6945fab3e 100644 --- a/src/Model/GServer.php +++ b/src/Model/GServer.php @@ -2145,7 +2145,7 @@ class GServer */ private static function discoverFederation() { - $last = DI::config()->get('poco', 'last_federation_discovery'); + $last = DI::keyValue()->get('poco_last_federation_discovery'); if ($last) { $next = $last + (24 * 60 * 60); @@ -2189,7 +2189,7 @@ class GServer } } - DI::config()->set('poco', 'last_federation_discovery', time()); + DI::keyValue()->set('poco_last_federation_discovery', time()); } /** diff --git a/update.php b/update.php index ff3b6b536..9aaf95193 100644 --- a/update.php +++ b/update.php @@ -1149,18 +1149,25 @@ function update_1502() function update_1505() { $conditions = [ - "(`cat` = ?) AND ((`k` LIKE ?) OR (`k` = ?) OR (`k` LIKE ?) OR (`k` = ?))", + "((`cat` = ?) AND ((`k` LIKE ?) OR (`k` = ?) OR (`k` LIKE ?) OR (`k` = ?))) OR " . + "((`cat` != ?) AND (`k` LIKE ?))", "system", "post_update_%", "worker_last_cleaned", "last%", "worker_daemon_mode", + "system", + "last_%", ]; - $postUpdateEntries = DBA::selectToArray('config', ['k', 'v'], $conditions); + $postUpdateEntries = DBA::selectToArray('config', ['cat', 'k', 'v'], $conditions); foreach ($postUpdateEntries as $postUpdateEntry) { - DI::keyValue()->set($postUpdateEntry['k'], $postUpdateEntry['v']); + if ($postUpdateEntry['cat'] === 'system') { + DI::keyValue()->set($postUpdateEntry['k'], $postUpdateEntry['v']); + } else { + DI::keyValue()->set(sprintf('%s_%s', $postUpdateEntry['cat'], $postUpdateEntry['k']), $postUpdateEntry['v']); + } } return DBA::delete('config', $conditions) ? Update::SUCCESS : Update::FAILED;