diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2025-06-02 17:45:35 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2025-06-05 17:58:54 +0200 |
commit | e8370bf73a77f7fd75dc313ca8d2f746d2ca2a73 (patch) | |
tree | b67136b51413040eca1b3d4b5d375db732210a5b | |
parent | 0d78c6075948ce4a46adffcd97f742848e9e8a57 (diff) | |
download | nextcloud-server-e8370bf73a77f7fd75dc313ca8d2f746d2ca2a73.tar.gz nextcloud-server-e8370bf73a77f7fd75dc313ca8d2f746d2ca2a73.zip |
fix: Use only enabled applications versions in the cache prefix
This makes sure the cached routes are updated after enabling a
previously disabled application
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r-- | lib/private/App/AppManager.php | 7 | ||||
-rw-r--r-- | lib/private/AppConfig.php | 9 | ||||
-rw-r--r-- | lib/private/AppFramework/Services/AppConfig.php | 4 | ||||
-rw-r--r-- | lib/private/Server.php | 2 | ||||
-rw-r--r-- | lib/private/TemplateLayout.php | 2 | ||||
-rw-r--r-- | lib/public/App/IAppManager.php | 2 | ||||
-rw-r--r-- | lib/public/IAppConfig.php | 2 |
7 files changed, 18 insertions, 10 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 18f29114d0e..d4dc8c74960 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -18,6 +18,7 @@ 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; @@ -134,7 +135,7 @@ class AppManager implements IAppManager { */ private function getEnabledAppsValues(): array { if (!$this->enabledAppsCache) { - $values = $this->getAppConfig()->getValues(false, 'enabled'); + $values = $this->getAppConfig()->searchValues('enabled', false, IAppConfig::VALUE_STRING); $alwaysEnabledApps = $this->getAlwaysEnabledApps(); foreach ($alwaysEnabledApps as $appId) { @@ -784,8 +785,8 @@ class AppManager implements IAppManager { * * @return array<string, string> */ - public function getAppInstalledVersions(): array { - return $this->getAppConfig()->getAppInstalledVersions(); + public function getAppInstalledVersions(bool $onlyEnabled = false): array { + return $this->getAppConfig()->getAppInstalledVersions($onlyEnabled); } /** diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index a8a6f689ffa..adbfc58978b 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -1670,11 +1670,18 @@ class AppConfig implements IAppConfig { * * @return array<string, string> */ - public function getAppInstalledVersions(): array { + public function getAppInstalledVersions(bool $onlyEnabled = false): array { if ($this->appVersionsCache === null) { /** @var array<string, string> */ $this->appVersionsCache = $this->searchValues('installed_version', false, IAppConfig::VALUE_STRING); } + if ($onlyEnabled) { + return array_filter( + $this->appVersionsCache, + fn (string $app): bool => $this->getValueString($app, 'enabled', 'no') !== 'no', + ARRAY_FILTER_USE_KEY + ); + } return $this->appVersionsCache; } } diff --git a/lib/private/AppFramework/Services/AppConfig.php b/lib/private/AppFramework/Services/AppConfig.php index 77c5ea4de0c..04d97738483 100644 --- a/lib/private/AppFramework/Services/AppConfig.php +++ b/lib/private/AppFramework/Services/AppConfig.php @@ -343,7 +343,7 @@ class AppConfig implements IAppConfig { * * @return array<string, string> */ - public function getAppInstalledVersions(): array { - return $this->appConfig->getAppInstalledVersions(); + public function getAppInstalledVersions(bool $onlyEnabled = false): array { + return $this->appConfig->getAppInstalledVersions($onlyEnabled); } } diff --git a/lib/private/Server.php b/lib/private/Server.php index bf07ee355ea..ae4096ac894 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -605,7 +605,7 @@ class Server extends ServerContainer implements IServerContainer { $prefixClosure = function () use ($logQuery, $serverVersion): ?string { if (!$logQuery) { try { - $v = \OCP\Server::get(IAppConfig::class)->getAppInstalledVersions(); + $v = \OCP\Server::get(IAppConfig::class)->getAppInstalledVersions(true); } catch (\Doctrine\DBAL\Exception $e) { // Database service probably unavailable // Probably related to https://github.com/nextcloud/server/issues/37424 diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index caffbfceefa..cfc387d2164 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -201,7 +201,7 @@ class TemplateLayout { if ($this->config->getSystemValueBool('installed', false)) { if (empty(self::$versionHash)) { - $v = $this->appManager->getAppInstalledVersions(); + $v = $this->appManager->getAppInstalledVersions(true); $v['core'] = implode('.', $this->serverVersion->getVersion()); self::$versionHash = substr(md5(implode(',', $v)), 0, 8); } diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 67ef2d796be..6eae870216f 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -57,7 +57,7 @@ interface IAppManager { * @return array<string, string> * @since 32.0.0 */ - public function getAppInstalledVersions(): array; + public function getAppInstalledVersions(bool $onlyEnabled = false): array; /** * Returns the app icon or null if none is found diff --git a/lib/public/IAppConfig.php b/lib/public/IAppConfig.php index f4210793476..fcc528fe11f 100644 --- a/lib/public/IAppConfig.php +++ b/lib/public/IAppConfig.php @@ -514,5 +514,5 @@ interface IAppConfig { * @return array<string, string> * @since 32.0.0 */ - public function getAppInstalledVersions(): array; + public function getAppInstalledVersions(bool $onlyEnabled = false): array; } |