From 9998861402d9b16e2e7d8ebd9382633fc91a5dae Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 17 Oct 2014 12:28:27 +0200 Subject: [PATCH] Encapsulate require_once to avoid name space bleedind The script required by require_once might use variable names like $app which will conflict with the code that follows. This fix encapsulates require_once into its own function to avoid such issues. --- lib/private/app.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/private/app.php b/lib/private/app.php index d58c851b8147..20c0f5f50aed 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -92,7 +92,7 @@ public static function loadApp($app, $checkUpgrade = true) { if ($checkUpgrade and self::shouldUpgrade($app)) { throw new \OC\NeedsUpdateException(); } - require_once $app . '/appinfo/app.php'; + self::requireAppFile($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 @@ -103,6 +103,16 @@ public static function loadApp($app, $checkUpgrade = true) { } } + /** + * Load app.php from the given app + * + * @param string $app app name + */ + private static function requireAppFile($app) { + // encapsulated here to avoid variable scope conflicts + require_once $app . '/appinfo/app.php'; + } + /** * check if an app is of a specific type *