From: Philipp <admin@philipp.info>
Date: Thu, 29 Dec 2022 19:51:04 +0000 (+0100)
Subject: Replace addon "last" config entries with key-value entries
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1ed67fba3d0e33d10bf6112a15b9e086a6a5ee89;p=friendica.git

Replace addon "last" config entries with key-value entries
---

diff --git a/src/Model/GServer.php b/src/Model/GServer.php
index b0a9dd5c9a..6945fab3e0 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 ff3b6b5362..9aaf95193b 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;