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>
pull/52793/head
Côme Chilliet 7 months ago
parent 0d78c60759
commit e8370bf73a
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
  1. 7
      lib/private/App/AppManager.php
  2. 9
      lib/private/AppConfig.php
  3. 4
      lib/private/AppFramework/Services/AppConfig.php
  4. 2
      lib/private/Server.php
  5. 2
      lib/private/TemplateLayout.php
  6. 2
      lib/public/App/IAppManager.php
  7. 2
      lib/public/IAppConfig.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);
}
/**

@ -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;
}
}

@ -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);
}
}

@ -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

@ -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);
}

@ -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

@ -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;
}

Loading…
Cancel
Save