From: Deepak Srivastava Date: Mon, 23 Sep 2013 13:55:04 +0000 (+0530) Subject: CRM-13302 - webtest fix - WebTest_Contact_CustomDataAddTest X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=12de149ab66574dce6ddac8210dadcfc18ccfb09;p=civicrm-core.git CRM-13302 - webtest fix - WebTest_Contact_CustomDataAddTest --- diff --git a/CRM/Core/BAO/SchemaHandler.php b/CRM/Core/BAO/SchemaHandler.php index ddfc60fec5..5914a406a1 100644 --- a/CRM/Core/BAO/SchemaHandler.php +++ b/CRM/Core/BAO/SchemaHandler.php @@ -298,7 +298,7 @@ ALTER TABLE {$tableName} // logging support: if we’re adding a column (but only then!) make sure the potential relevant log table gets a column as well if ($params['operation'] == 'add') { $logging = new CRM_Logging_Schema; - $logging->fixSchemaDifferencesFor($params['table_name'], array($params['name']), FALSE); + $logging->fixSchemaDifferencesFor($params['table_name'], array('ADD' => array($params['name'])), FALSE); } } diff --git a/CRM/Logging/Schema.php b/CRM/Logging/Schema.php index 5b98d126e1..f20209a4e6 100644 --- a/CRM/Logging/Schema.php +++ b/CRM/Logging/Schema.php @@ -200,9 +200,11 @@ AND TABLE_NAME LIKE 'log_civicrm_%' // use the relevant lines from CREATE TABLE to add colums to the log table $create = $this->_getCreateQuery($table); foreach ((array('ADD', 'MODIFY')) as $alterType) { - foreach ($cols[$alterType] as $col) { - $line = $this->_getColumnQuery($col, $create); - CRM_Core_DAO::executeQuery("ALTER TABLE `{$this->db}`.log_$table {$alterType} {$line}"); + if (!empty($cols[$alterType])) { + foreach ($cols[$alterType] as $col) { + $line = $this->_getColumnQuery($col, $create); + CRM_Core_DAO::executeQuery("ALTER TABLE `{$this->db}`.log_$table {$alterType} {$line}"); + } } } @@ -376,7 +378,7 @@ WHERE table_schema IN ('{$this->db}', '{$civiDB}')"; // wasn't deliberately modified by fixTimeStampAndNotNullSQL() method. foreach ($civiTableSpecs as $col => $colSpecs) { $specDiff = array_diff($civiTableSpecs[$col], $logTableSpecs[$col]); - if (!empty($specDiff) && $col != 'id') { + if (!empty($specDiff) && $col != 'id' && !array_key_exists($col, $diff['ADD'])) { // ignore 'id' column for any spec changes, to avoid any auto-increment mysql errors if ($civiTableSpecs[$col]['DATA_TYPE'] != $logTableSpecs[$col]['DATA_TYPE']) { // if data-type is different, surely consider the column