Merge pull request #22376 from owncloud/fix-return-code-getAppPath

Properly handle return code of OC_App::getAppPath
This commit is contained in:
Thomas Müller 2016-02-15 16:58:37 +01:00
commit 3ab328350a
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());
@ -806,15 +814,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);
@ -1111,14 +1122,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