0012090: Tine 2.0 dependencies are raising php min level to 5.5
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 15 Aug 2016 14:04:38 +0000 (16:04 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 17 Aug 2016 13:08:51 +0000 (15:08 +0200)
* check if doctrine is available and php version is high enough
 before installing modelconfig v2 apps

 https://forge.tine20.org/view.php?id=12090

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

index 4bd9768..1096741 100644 (file)
@@ -1465,20 +1465,23 @@ class Setup_Controller
                 }
             }
 
-            // do we have modelconfig
+            // do we have modelconfig + doctrine
             else {
-                // create tables using doctrine 2
                 $application = Setup_Core::getApplicationInstance($_xml->name, '', true);
                 $models = $application->getModels(true /* MCv2only */);
-                Setup_SchemaTool::createSchema($_xml->name, $models);
-
-                // adopt to old workflow
-                foreach($models as $model) {
-                    $modelConfiguration = $model::getConfiguration();
-                    $createdTables[] = (object) array(
-                        'name' => Tinebase_Helper::array_value('name', $modelConfiguration->getTable()),
-                        'version' => $modelConfiguration->getVersion(),
-                    );
+
+                if (count($models) > 0) {
+                    // create tables using doctrine 2
+                    Setup_SchemaTool::createSchema($_xml->name, $models);
+
+                    // adopt to old workflow
+                    foreach ($models as $model) {
+                        $modelConfiguration = $model::getConfiguration();
+                        $createdTables[] = (object)array(
+                            'name' => Tinebase_Helper::array_value('name', $modelConfiguration->getTable()),
+                            'version' => $modelConfiguration->getVersion(),
+                        );
+                    }
                 }
             }
     
index 806745d..511d062 100644 (file)
@@ -294,4 +294,14 @@ class Setup_Core extends Tinebase_Core
         // disable caching for setup
         parent::setupCache(false);
     }
+
+    /**
+     * returns TRUE if doctrine is available for model config v2 stuff
+     *
+     * @return bool
+     */
+    public static function isDoctrineAvailable()
+    {
+        return PHP_VERSION_ID >= 50500 && interface_exists('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver');
+    }
 }
index 6414133..7d7a58d 100755 (executable)
@@ -306,6 +306,12 @@ abstract class Tinebase_Controller_Abstract extends Tinebase_Pluggable_Abstract
         }
 
         if ($MCV2only) {
+            if (! Setup_Core::isDoctrineAvailable()) {
+                if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__
+                    . ' Doctrine not available, could not get modelconfig v2 models for application (php version id: ' . PHP_VERSION_ID . ')');
+                return array();
+            }
+
             $md = new Tinebase_Record_DoctrineMappingDriver();
             $MCv2Models = array();
             foreach ((array)$this->_models as $model) {