0011976: prevent open_basedir error in searchServerPlugins
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 2 May 2016 08:49:34 +0000 (10:49 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 11 Jul 2016 12:19:51 +0000 (14:19 +0200)
https://forge.tine20.org/view.php?id=11976

Change-Id: Id01d3f324c27e028f5af31bac67050d6a063cc8f
Reviewed-on: http://gerrit.tine20.com/customers/3119
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Core.php

index e0a6835..0b542a2 100644 (file)
@@ -1605,6 +1605,9 @@ class Tinebase_Core
     /**
      * Search server plugins from applications configuration
      *
+     * @return array
+     *
+     * TODO add feature switch for this
      */
     protected static function _searchServerPlugins()
     {
@@ -1615,32 +1618,21 @@ class Tinebase_Core
         ) {
             return $plugins;
         }
-        
-        // get list of available applications
-        $applications = array();
-        
-        $d = dir(realpath(__DIR__ . '/../'));
-        
-        while (false !== ($entry = $d->read())) {
-           if ($entry[0] == '.') {
-               continue;
-           }
-           
-           if (ctype_upper($entry[0]) && is_dir($d->path . DIRECTORY_SEPARATOR . $entry)) {
-                $applications[] = $entry;
-           }
+
+        if (! Setup_Controller::getInstance()->isInstalled('Tinebase')) {
+            return array();
         }
         
-        $d->close();
+        // get list of available applications
+        $applications = Tinebase_Application::getInstance()->getApplicationsByState(Tinebase_Application::ENABLED)->name;
         
         // get list of plugins
         $plugins = array();
-        
         foreach ($applications as $application) {
             $config = $application . '_Config';
             
             try {
-                if (class_exists($config)) {
+                if (@class_exists($config)) {
                     $reflectedClass = new ReflectionClass($config);
                     
                     if ($reflectedClass->isSubclassOf('Tinebase_Config_Abstract')) {