diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-25 10:02:02 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-25 10:02:02 +0100 |
commit | d69167caff54c97d5aa13bd47262a4309a1c6999 (patch) | |
tree | 1ca7c4faffbe1d065e4c6b332ea3340843f5ba65 | |
parent | adf532fe4e45c529fd0f4a3605cc3e13762642a9 (diff) | |
parent | a3cbdcf202ee1b28fb3109c91e4d32194bdeebb6 (diff) | |
download | nextcloud-server-d69167caff54c97d5aa13bd47262a4309a1c6999.tar.gz nextcloud-server-d69167caff54c97d5aa13bd47262a4309a1c6999.zip |
Merge pull request #21424 from owncloud/appversions
Use appConfig to get app versions
-rw-r--r-- | lib/private/app.php | 19 | ||||
-rw-r--r-- | lib/private/appconfig.php | 13 |
2 files changed, 11 insertions, 21 deletions
diff --git a/lib/private/app.php b/lib/private/app.php index f49db15defe..2abc015a91f 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -1024,21 +1024,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; } diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php index cd3362e0091..035495992ef 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); } } |