From ae7c49f93c7de919d0859abb5c75695c194dd2ff Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 3 Jan 2016 16:53:30 +0100 Subject: [PATCH 1/2] Use appconfig for getAppVersions --- lib/private/app.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/lib/private/app.php b/lib/private/app.php index 705d60cf8d..bfec84759f 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -1022,21 +1022,12 @@ class OC_App { */ public static function getAppVersions() { static $versions; - if (isset($versions)) { // simple cache, needs to be fixed - return $versions; // when function is used besides in checkUpgrade - } - $versions = array(); - try { - $query = OC_DB::prepare('SELECT `appid`, `configvalue` FROM `*PREFIX*appconfig`' - . ' WHERE `configkey` = \'installed_version\''); - $result = $query->execute(); - while ($row = $result->fetchRow()) { - $versions[$row['appid']] = $row['configvalue']; - } - return $versions; - } catch (\Exception $e) { - return array(); + + if(!$versions) { + $appConfig = \OC::$server->getAppConfig(); + $versions = $appConfig->getValues(false, 'installed_version'); } + return $versions; } From a3cbdcf202ee1b28fb3109c91e4d32194bdeebb6 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 3 Jan 2016 16:53:44 +0100 Subject: [PATCH 2/2] Faster AppConfig->getValues --- lib/private/appconfig.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php index d1c1e4bfc4..17e474bd77 100644 --- a/lib/private/appconfig.php +++ b/lib/private/appconfig.php @@ -251,14 +251,13 @@ class AppConfig implements IAppConfig { if ($key === false) { return $this->getAppValues($app); } else { - $configs = []; - foreach ($this->getApps() as $appId) { - if ($this->hasKey($appId, $key)) { - $configs[$appId] = $this->getValue($appId, $key); - } - } + $appIds = $this->getApps(); + $values = array_map(function($appId) use ($key) { + return isset($this->cache[$appId][$key]) ? $this->cache[$appId][$key] : null; + }, $appIds); + $result = array_combine($appIds, $values); - return $configs; + return array_filter($result); } }