diff options
-rw-r--r-- | lib/private/App/AppManager.php | 9 | ||||
-rw-r--r-- | lib/private/AppConfig.php | 16 | ||||
-rw-r--r-- | lib/private/AppFramework/Services/AppConfig.php | 9 | ||||
-rw-r--r-- | lib/private/Server.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/OC_App.php | 13 | ||||
-rw-r--r-- | lib/public/IAppConfig.php | 8 |
6 files changed, 38 insertions, 19 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index d7fd0c33a30..740da31770d 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -19,7 +19,6 @@ use OCP\Collaboration\AutoComplete\IManager as IAutoCompleteManager; use OCP\Collaboration\Collaborators\ISearch as ICollaboratorSearch; use OCP\Diagnostics\IEventLogger; use OCP\EventDispatcher\IEventDispatcher; -use OCP\IAppConfig; use OCP\ICacheFactory; use OCP\IConfig; use OCP\IGroup; @@ -818,13 +817,7 @@ class AppManager implements IAppManager { * @return array<string, string> */ public function getAppInstalledVersions(): array { - static $versions; - - if (!$versions) { - /** @var array<string, string> */ - $versions = $this->getAppConfig()->searchValues('installed_version', false, IAppConfig::VALUE_STRING); - } - return $versions; + return $this->getAppConfig()->getAppInstalledVersions(); } /** diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index ad9299f01fd..1228b9c20e3 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -62,6 +62,9 @@ class AppConfig implements IAppConfig { /** @var array<array-key, array{entries: array<array-key, ConfigLexiconEntry>, strictness: ConfigLexiconStrictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ private array $configLexiconDetails = []; + /** @var ?array<string, string> */ + private ?array $appVersionsCache = null; + public function __construct( protected IDBConnection $connection, protected LoggerInterface $logger, @@ -1647,4 +1650,17 @@ class AppConfig implements IAppConfig { return $this->configLexiconDetails[$appId]; } + + /** + * Returns the installed versions of all apps + * + * @return array<string, string> + */ + public function getAppInstalledVersions(): array { + if ($this->appVersionsCache === null) { + /** @var array<string, string> */ + $this->appVersionsCache = $this->searchValues('installed_version', false, IAppConfig::VALUE_STRING); + } + return $this->appVersionsCache; + } } diff --git a/lib/private/AppFramework/Services/AppConfig.php b/lib/private/AppFramework/Services/AppConfig.php index 423a9eb5814..77c5ea4de0c 100644 --- a/lib/private/AppFramework/Services/AppConfig.php +++ b/lib/private/AppFramework/Services/AppConfig.php @@ -337,4 +337,13 @@ class AppConfig implements IAppConfig { public function deleteUserValue(string $userId, string $key): void { $this->config->deleteUserValue($userId, $this->appName, $key); } + + /** + * Returns the installed versions of all apps + * + * @return array<string, string> + */ + public function getAppInstalledVersions(): array { + return $this->appConfig->getAppInstalledVersions(); + } } diff --git a/lib/private/Server.php b/lib/private/Server.php index 0b37c2e2abb..4d79fefd261 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -610,7 +610,7 @@ class Server extends ServerContainer implements IServerContainer { $prefixClosure = function () use ($logQuery, $serverVersion): ?string { if (!$logQuery) { try { - $v = \OC_App::getAppVersions(); + $v = \OCP\Server::get(IAppConfig::class)->getAppInstalledVersions(); } catch (\Doctrine\DBAL\Exception $e) { // Database service probably unavailable // Probably related to https://github.com/nextcloud/server/issues/37424 diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index 8f3284b0955..ecceafa65b3 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -642,17 +642,10 @@ class OC_App { /** * get the installed version of all apps - * @deprecated 32.0.0 Use IAppManager::getAppInstalledVersions instead + * @deprecated 32.0.0 Use IAppManager::getAppInstalledVersions or IAppConfig::getAppInstalledVersions instead */ - public static function getAppVersions() { - static $versions; - - if (!$versions) { - /** @var IAppConfig $appConfig */ - $appConfig = \OCP\Server::get(IAppConfig::class); - $versions = $appConfig->searchValues('installed_version'); - } - return $versions; + public static function getAppVersions(): array { + return \OCP\Server::get(IAppConfig::class)->getAppInstalledVersions(); } /** diff --git a/lib/public/IAppConfig.php b/lib/public/IAppConfig.php index d4d5c1c09c7..f4210793476 100644 --- a/lib/public/IAppConfig.php +++ b/lib/public/IAppConfig.php @@ -507,4 +507,12 @@ interface IAppConfig { * @deprecated 29.0.0 Use {@see getAllValues()} or {@see searchValues()} */ public function getFilteredValues($app); + + /** + * Returns the installed version of all apps + * + * @return array<string, string> + * @since 32.0.0 + */ + public function getAppInstalledVersions(): array; } |