]> source.dussan.org Git - nextcloud-server.git/commitdiff
Encapsulate require_once to avoid name space bleedind
authorVincent Petry <pvince81@owncloud.com>
Fri, 17 Oct 2014 10:28:27 +0000 (12:28 +0200)
committerVincent Petry <pvince81@owncloud.com>
Fri, 17 Oct 2014 10:45:45 +0000 (12:45 +0200)
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

index faaadef38574025e875a1c3e1fe947adc03b076e..a97db7b5e53fd6202f8fce413c0614f7515fe627 100644 (file)
@@ -92,7 +92,7 @@ class OC_App {
                        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 @@ class OC_App {
                }
        }
 
+       /**
+        * 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
         *