diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2016-12-09 22:43:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-09 22:43:21 +0100 |
commit | 4f3f799e068161e72f96abb6b06ea49c2c80f91a (patch) | |
tree | b8dd4f9c34f81a85942b89714b5c36d3e02e41e6 | |
parent | 9dc29aa24f0611b6ce24fb1cfc6dbd273b543cce (diff) | |
parent | 32bf8ec826dadbfd342627884fbdf83081db9b29 (diff) | |
download | nextcloud-server-4f3f799e068161e72f96abb6b06ea49c2c80f91a.tar.gz nextcloud-server-4f3f799e068161e72f96abb6b06ea49c2c80f91a.zip |
Merge pull request #2594 from nextcloud/dont-use-cached-info
Don't use cached informations for app version when installing the app
-rw-r--r-- | lib/private/Installer.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/app.php | 11 | ||||
-rw-r--r-- | tests/lib/InstallerTest.php | 4 |
3 files changed, 12 insertions, 5 deletions
diff --git a/lib/private/Installer.php b/lib/private/Installer.php index db71f7b1432..38d0ce13684 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -121,7 +121,7 @@ class Installer { OC_App::executeRepairSteps($appId, $appData['repair-steps']['install']); //set the installed version - \OC::$server->getConfig()->setAppValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id'])); + \OC::$server->getConfig()->setAppValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id'], false)); \OC::$server->getConfig()->setAppValue($info['id'], 'enabled', 'no'); //set remote/public handlers diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 0d9adfa9d2b..adf29601ac6 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -653,13 +653,16 @@ class OC_App { * get the last version of the app from appinfo/info.xml * * @param string $appId + * @param bool $useCache * @return string */ - public static function getAppVersion($appId) { - if (!isset(self::$appVersion[$appId])) { - $file = self::getAppPath($appId); - self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0'; + public static function getAppVersion($appId, $useCache = true) { + if($useCache && isset(self::$appVersion[$appId])) { + return self::$appVersion[$appId]; } + + $file = self::getAppPath($appId); + self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0'; return self::$appVersion[$appId]; } diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php index dadaffe1879..d1923970588 100644 --- a/tests/lib/InstallerTest.php +++ b/tests/lib/InstallerTest.php @@ -73,6 +73,9 @@ class InstallerTest extends TestCase { } public function testInstallApp() { + // Read the current version of the app to check for bug #2572 + \OC_App::getAppVersion('testapp'); + // Extract app $pathOfTestApp = __DIR__ . '/../data/testapp.zip'; $tar = new ZIP($pathOfTestApp); @@ -88,6 +91,7 @@ class InstallerTest extends TestCase { $installer->installApp(self::$appid); $isInstalled = Installer::isInstalled(self::$appid); $this->assertTrue($isInstalled); + $this->assertSame('0.9', \OC::$server->getConfig()->getAppValue('testapp', 'installed_version')); $installer->removeApp(self::$appid); } |