diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-02-14 22:57:09 +0300 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-02-14 22:57:09 +0300 |
commit | ef49f6ef5de3cd5321083a5be392caee1b6e6cdc (patch) | |
tree | cc67ad2b25faa809cf96a41083307e4c750e51e2 /lib/private/app.php | |
parent | ac367b97f0567481d3496a213c04eeb5cf654a9f (diff) |
Properly handle return code of OC_App::getAppPath
* fixes #20128
* getAppPath could return false, but it was not handled everywhere
Diffstat (limited to 'lib/private/app.php')
-rw-r--r-- | lib/private/app.php | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/lib/private/app.php b/lib/private/app.php index 3df3a0e5bac..e3da1b1cfcc 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -132,8 +132,12 @@ class OC_App { */ public static function loadApp($app, $checkUpgrade = true) { self::$loadedApps[] = $app; - \OC::$loader->addValidRoot(self::getAppPath($app)); // in case someone calls loadApp() directly - if (is_file(self::getAppPath($app) . '/appinfo/app.php')) { + $appPath = self::getAppPath($app); + if($appPath === false) { + return; + } + \OC::$loader->addValidRoot($appPath); // in case someone calls loadApp() directly + if (is_file($appPath . '/appinfo/app.php')) { \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app); if ($checkUpgrade and self::shouldUpgrade($app)) { throw new \OC\NeedsUpdateException(); @@ -605,7 +609,11 @@ class OC_App { if (isset(self::$appInfo[$appId])) { return self::$appInfo[$appId]; } - $file = self::getAppPath($appId) . '/appinfo/info.xml'; + $appPath = self::getAppPath($appId); + if($appPath === false) { + return null; + } + $file = $appPath . '/appinfo/info.xml'; } $parser = new \OC\App\InfoParser(\OC::$server->getHTTPHelper(), \OC::$server->getURLGenerator()); @@ -807,15 +815,18 @@ class OC_App { $info['update'] = ($includeUpdateInfo) ? OC_Installer::isUpdateAvailable($app) : null; - $appIcon = self::getAppPath($app) . '/img/' . $app . '.svg'; - if (file_exists($appIcon)) { - $info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, $app . '.svg'); - $info['previewAsIcon'] = true; - } else { - $appIcon = self::getAppPath($app) . '/img/app.svg'; + $appPath = self::getAppPath($app); + if($appPath !== false) { + $appIcon = $appPath . '/img/' . $app . '.svg'; if (file_exists($appIcon)) { - $info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, 'app.svg'); + $info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, $app . '.svg'); $info['previewAsIcon'] = true; + } else { + $appIcon = $appPath . '/img/app.svg'; + if (file_exists($appIcon)) { + $info['preview'] = \OC::$server->getURLGenerator()->imagePath($app, 'app.svg'); + $info['previewAsIcon'] = true; + } } } $info['version'] = OC_App::getAppVersion($app); @@ -1112,14 +1123,18 @@ class OC_App { * @return bool */ public static function updateApp($appId) { - if (file_exists(self::getAppPath($appId) . '/appinfo/database.xml')) { - OC_DB::updateDbFromStructure(self::getAppPath($appId) . '/appinfo/database.xml'); + $appPath = self::getAppPath($appId); + if($appPath === false) { + return false; + } + if (file_exists($appPath . '/appinfo/database.xml')) { + OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); } unset(self::$appVersion[$appId]); // run upgrade code - if (file_exists(self::getAppPath($appId) . '/appinfo/update.php')) { + if (file_exists($appPath . '/appinfo/update.php')) { self::loadApp($appId, false); - include self::getAppPath($appId) . '/appinfo/update.php'; + include $appPath . '/appinfo/update.php'; } //set remote/public handlers |