diff --git a/changelog/unreleased/39108 b/changelog/unreleased/39108 new file mode 100644 index 000000000000..a07cb5e7b701 --- /dev/null +++ b/changelog/unreleased/39108 @@ -0,0 +1,15 @@ +Bugfix: Update appinfo cache only if the app version is newer + +Previously, in case there were multiple copies of the same app with different +versions, the information being cached was the latest one found based on the +locations defined in the config.php file, which might not be the one from the +latest app version. This might be a problem in some scenarios specially checking +the version of the app. Note that the code used was the one from the latest app +version found. + +Now, the information cached is always from the latest version found. In the +weird case that both versions are the same, the information from the first one +will be kept. This shouldn't be a problem because the information is expected +to be the same. + +https://github.com/owncloud/core/pull/39108 diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index cd0d1d69e56b..c238e03ee6d4 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -511,7 +511,11 @@ public function getAppInfoByPath($path, $etag = null) { ]; // cache results for a day - $this->appInfo->set($appId, $data, 86400); + $appIdData = $this->appInfo->get($appId); + if ($appIdData === null || \version_compare($appIdData['info']['version'], $info['version']) === -1) { + // if no data is cached for the appId or the new one has a higher version, update cache + $this->appInfo->set($appId, $data, 86400); + } $this->appInfo->set($file, $data, 86400); return $info;