From eb59d6696a5611b36a751a3c5adf7a6315f38828 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 6 Dec 2018 19:59:49 +1100 Subject: [PATCH] dev/core#576 Fix the generation of DAO files because version comparision fails and use standard version_compare function to assit us --- CRM/Core/CodeGen/Specification.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CRM/Core/CodeGen/Specification.php b/CRM/Core/CodeGen/Specification.php index faaaacce7d..c23b925088 100644 --- a/CRM/Core/CodeGen/Specification.php +++ b/CRM/Core/CodeGen/Specification.php @@ -94,11 +94,11 @@ class CRM_Core_CodeGen_Specification { $tables = array(); foreach ($dbXML->tables as $tablesXML) { foreach ($tablesXML->table as $tableXML) { - if ($this->value('drop', $tableXML, 0) > 0 and $this->value('drop', $tableXML, 0) <= $this->buildVersion) { + if ($this->value('drop', $tableXML, 0) > 0 && version_compare($this->value('drop', $tableXML, 0), $this->buildVersion, '<=')) { continue; } - if ($this->value('add', $tableXML, 0) <= $this->buildVersion) { + if (version_compare($this->value('add', $tableXML, 0), $this->buildVersion, '<=')) { $this->getTable($tableXML, $database, $tables); } } @@ -222,11 +222,11 @@ class CRM_Core_CodeGen_Specification { $fields = array(); foreach ($tableXML->field as $fieldXML) { - if ($this->value('drop', $fieldXML, 0) > 0 and $this->value('drop', $fieldXML, 0) <= $this->buildVersion) { + if ($this->value('drop', $fieldXML, 0) > 0 && version_compare($this->value('drop', $fieldXML, 0), $this->buildVersion, '<=')) { continue; } - if ($this->value('add', $fieldXML, 0) <= $this->buildVersion) { + if (version_compare($this->value('add', $fieldXML, 0), $this->buildVersion, '<=')) { $this->getField($fieldXML, $fields); } } @@ -240,7 +240,7 @@ class CRM_Core_CodeGen_Specification { if ($this->value('index', $tableXML)) { $index = array(); foreach ($tableXML->index as $indexXML) { - if ($this->value('drop', $indexXML, 0) > 0 and $this->value('drop', $indexXML, 0) <= $this->buildVersion) { + if ($this->value('drop', $indexXML, 0) > 0 && version_compare($this->value('drop', $indexXML, 0), $this->buildVersion, '<=')) { continue; } @@ -254,10 +254,10 @@ class CRM_Core_CodeGen_Specification { $foreign = array(); foreach ($tableXML->foreignKey as $foreignXML) { - if ($this->value('drop', $foreignXML, 0) > 0 and $this->value('drop', $foreignXML, 0) <= $this->buildVersion) { + if ($this->value('drop', $foreignXML, 0) > 0 && version_compare($this->value('drop', $foreignXML, 0), $this->buildVersion, '<=')) { continue; } - if ($this->value('add', $foreignXML, 0) <= $this->buildVersion) { + if (version_compare($this->value('add', $foreignXML, 0), $this->buildVersion, '<=')) { $this->getForeignKey($foreignXML, $fields, $foreign, $name); } } @@ -267,10 +267,10 @@ class CRM_Core_CodeGen_Specification { if ($this->value('dynamicForeignKey', $tableXML)) { $dynamicForeign = array(); foreach ($tableXML->dynamicForeignKey as $foreignXML) { - if ($this->value('drop', $foreignXML, 0) > 0 and $this->value('drop', $foreignXML, 0) <= $this->buildVersion) { + if ($this->value('drop', $foreignXML, 0) > 0 && version_compare($this->value('drop', $foreignXML, 0), $this->buildVersion, '<=')) { continue; } - if ($this->value('add', $foreignXML, 0) <= $this->buildVersion) { + if (version_compare($this->value('add', $foreignXML, 0), $this->buildVersion, '<=')) { $this->getDynamicForeignKey($foreignXML, $dynamicForeign, $name); } } -- 2.25.1