Properly handle return code of OC_App::getAppPath

* fixes #20128
* getAppPath could return false, but it was not handled everywhere
This commit is contained in:
Morris Jobke 2016-02-14 20:57:09 +01:00
parent ac367b97f0
commit ef49f6ef5d
1 changed files with 29 additions and 14 deletions

View File

@ -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