diff --git a/lib/private/App/DependencyAnalyzer.php b/lib/private/App/DependencyAnalyzer.php index db9130badcd3..790c208731c8 100644 --- a/lib/private/App/DependencyAnalyzer.php +++ b/lib/private/App/DependencyAnalyzer.php @@ -223,6 +223,9 @@ private function analyzeLibraries(array $dependencies) { if (!is_array($libs)) { $libs = array($libs); } + if (isset($libs['@value'])) { + $libs = [$libs]; + } foreach ($libs as $lib) { $libName = $this->getValue($lib); $libVersion = $this->platform->getLibraryVersion($libName); diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 553ded280a43..f3db4067d26d 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -328,6 +328,13 @@ public static function enable($app, $groups = null) { self::$enabledAppsCache = array(); // flush if (!Installer::isInstalled($app)) { $app = self::installApp($app); + } else { + // check for required dependencies + $config = \OC::$server->getConfig(); + $l = \OC::$server->getL10N('core'); + $info = self::getAppInfo($app); + + self::checkAppDependencies($config, $l, $info); } $appManager = \OC::$server->getAppManager(); @@ -1159,16 +1166,7 @@ public static function installApp($app) { } // check for required dependencies - $dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l); - $missing = $dependencyAnalyzer->analyze($info); - if (!empty($missing)) { - $missingMsg = join(PHP_EOL, $missing); - throw new \Exception( - $l->t('App "%s" cannot be installed because the following dependencies are not fulfilled: %s', - array($info['name'], $missingMsg) - ) - ); - } + self::checkAppDependencies($config, $l, $info); $config->setAppValue($app, 'enabled', 'yes'); if (isset($appData['id'])) { @@ -1335,4 +1333,23 @@ public static function parseAppInfo(array $data) { return $data; } + + /** + * @param $config + * @param $l + * @param $info + * @throws Exception + */ + protected static function checkAppDependencies($config, $l, $info) { + $dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l); + $missing = $dependencyAnalyzer->analyze($info); + if (!empty($missing)) { + $missingMsg = join(PHP_EOL, $missing); + throw new \Exception( + $l->t('App "%s" cannot be installed because the following dependencies are not fulfilled: %s', + [$info['name'], $missingMsg] + ) + ); + } + } } diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php index 7882f6dd0315..aa7aecf8434a 100644 --- a/tests/lib/App/DependencyAnalyzerTest.php +++ b/tests/lib/App/DependencyAnalyzerTest.php @@ -9,7 +9,7 @@ namespace Test\App; -use OC; +use OC\App\DependencyAnalyzer; use OC\App\Platform; use OCP\IL10N; use Test\TestCase; @@ -22,7 +22,7 @@ class DependencyAnalyzerTest extends TestCase { /** @var IL10N */ private $l10nMock; - /** @var \OC\App\DependencyAnalyzer */ + /** @var DependencyAnalyzer */ private $analyser; public function setUp() { @@ -67,7 +67,7 @@ public function setUp() { return vsprintf($text, $parameters); })); - $this->analyser = new \OC\App\DependencyAnalyzer($this->platformMock, $this->l10nMock); + $this->analyser = new DependencyAnalyzer($this->platformMock, $this->l10nMock); } /** @@ -101,6 +101,8 @@ public function testPhpVersion($expectedMissing, $minVersion, $maxVersion, $intS /** * @dataProvider providesDatabases + * @param $expectedMissing + * @param $databases */ public function testDatabases($expectedMissing, $databases) { $app = array( @@ -247,6 +249,8 @@ function providesLibs() { array(array('@attributes' => array('min-version' => '2.3', 'max-version' => '2.3'), '@value' => 'curl'))), array(array(), array(array('@attributes' => array('min-version' => '2', 'max-version' => '2'), '@value' => 'curl'))), + array(array(), + array('@attributes' => array('min-version' => '2', 'max-version' => '2'), '@value' => 'curl')), ); }