From: Philipp Schüle
Date: Mon, 15 Aug 2016 14:04:38 +0000 (+0200)
Subject: 0012090: Tine 2.0 dependencies are raising php min level to 5.5
X-Git-Tag: 2016.09.1~8^2^2~6
X-Git-Url: http://git.tine20.org/?p=tine20;a=commitdiff_plain;h=2cfbc125a19f5acb9ee795ba0b81698182cbd9e0
0012090: Tine 2.0 dependencies are raising php min level to 5.5
* 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
---
diff --git a/tine20/Setup/Controller.php b/tine20/Setup/Controller.php
index 4bd9768..1096741 100644
--- a/tine20/Setup/Controller.php
+++ b/tine20/Setup/Controller.php
@@ -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(),
+ );
+ }
}
}
diff --git a/tine20/Setup/Core.php b/tine20/Setup/Core.php
index 806745d..511d062 100644
--- a/tine20/Setup/Core.php
+++ b/tine20/Setup/Core.php
@@ -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');
+ }
}
diff --git a/tine20/Tinebase/Controller/Abstract.php b/tine20/Tinebase/Controller/Abstract.php
index 6414133..7d7a58d 100755
--- a/tine20/Tinebase/Controller/Abstract.php
+++ b/tine20/Tinebase/Controller/Abstract.php
@@ -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) {