From 4bd0a3fe4dfbb444c285640cb58fd560900a7dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 15 Feb 2018 11:20:22 +0100 Subject: [PATCH 1/2] Properly encapsulate require_once for app.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/private/legacy/app.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 37de5fb491..5b64245da9 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -133,6 +133,7 @@ class OC_App { * load a single app * * @param string $app + * @throws Exception */ public static function loadApp($app) { self::$loadedApps[] = $app; @@ -146,7 +147,15 @@ class OC_App { if (is_file($appPath . '/appinfo/app.php')) { \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app); - self::requireAppFile($app); + try { + self::requireAppFile($app); + } catch (Error $ex) { + \OC::$server->getLogger()->logException($ex); + if (!\OC::$server->getAppManager()->isShipped($app)) { + // Only disable apps which are not shipped + self::disable($app); + } + } if (self::isType($app, array('authentication'))) { // since authentication apps affect the "is app enabled for group" check, // the enabled apps cache needs to be cleared to make sure that the @@ -204,16 +213,8 @@ class OC_App { * @param string $app app name */ private static function requireAppFile($app) { - try { - // encapsulated here to avoid variable scope conflicts - require_once $app . '/appinfo/app.php'; - } catch (Error $ex) { - \OC::$server->getLogger()->logException($ex); - if (!\OC::$server->getAppManager()->isShipped($app)) { - // Only disable apps which are not shipped - self::disable($app); - } - } + // encapsulated here to avoid variable scope conflicts + require_once $app . '/appinfo/app.php'; } /** From 251b21bb74fbdff5e14db67626c367f35f26c0f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 15 Feb 2018 12:23:49 +0100 Subject: [PATCH 2/2] Add throws annotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/private/legacy/app.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 5b64245da9..8e0a43a023 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -211,6 +211,7 @@ class OC_App { * Load app.php from the given app * * @param string $app app name + * @throws Error */ private static function requireAppFile($app) { // encapsulated here to avoid variable scope conflicts