Eileen has uploaded a new change for review. https://gerrit.wikimedia.org/r/297342
Change subject: CRM-19015 Merge data loss on zero fields (batch mode) ...................................................................... CRM-19015 Merge data loss on zero fields (batch mode) Please do review comments on the PR https://github.com/civicrm/civicrm-core/pull/8629 Note the slightly tangental change is to facilitate the test on the PR. Change-Id: Ifed0b4d46ccece8193b3d64e9366389de6537cd3 --- M CRM/Contact/BAO/Query.php M CRM/Dedupe/Merger.php 2 files changed, 28 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm/civicrm refs/changes/42/297342/1 diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index d7b02b6..d520a94 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -2144,8 +2144,7 @@ ); } elseif ($name === 'is_deceased') { - $this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $value); - $this->_qill[$grouping][] = "$field[title] $op \"$value\""; + $this->setQillAndWhere($name, $op, $value, $grouping, $field); self::$_openedPanes[ts('Demographics')] = TRUE; } elseif ($name === 'created_date' || $name === 'modified_date' || $name === 'deceased_date' || $name === 'birth_date') { @@ -2222,14 +2221,12 @@ $value = self::getWildCardedValue($wildcard, $op, $value); } - $wc = 'civicrm_website.url'; - $this->_where[$grouping][] = $d = self::buildClause($wc, $op, $value); + $this->_where[$grouping][] = $d = self::buildClause('civicrm_website.url', $op, $value); $this->_qill[$grouping][] = "$field[title] $op \"$value\""; + $this->setQillAndWhere('is_deleted', $op, $value, $grouping, $field); } elseif ($name === 'contact_is_deleted') { - $this->_where[$grouping][] = self::buildClause("contact_a.is_deleted", $op, $value); - list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $name, $value, $op); - $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['title'], 2 => $qillop, 3 => $qillVal)); + $this->setQillAndWhere('is_deleted', $op, $value, $grouping, $field); } elseif (!empty($field['where'])) { $type = NULL; @@ -6066,4 +6063,26 @@ return array($order, $additionalFromClause); } + /** + * Set the qill and where properties for a field. + * + * This function is intended as a short-term function to encourage refactoring + * & re-use - but really we should just have less special-casing. + * + * @param string $name + * @param string $op + * @param string|array $value + * @param string $grouping + * @param string $field + */ + public function setQillAndWhere($name, $op, $value, $grouping, $field) { + $this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $value); + list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $name, $value, $op); + $this->_qill[$grouping][] = ts("%1 %2 %3", array( + 1 => $field['title'], + 2 => $qillop, + 3 => $qillVal, + )); + } + } diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 44a7553..d7f0740 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -862,15 +862,9 @@ ) { // Rule: If both main-contact, and other-contact have a field with a // different value, then let $mode decide if to merge it or not + // Note that an integer of 0 should be treated as a value! if ( - (!empty($migrationInfo['rows'][$key]['main']) - // For custom fields a 0 (e.g in an int field) could be a true conflict. This - // is probably true for other fields too - e.g. 'do_not_email' but - // leaving that investigation as a @todo - until tests can be written. - // Note the handling of this has test coverage - although the data-typing - // of '0' feels flakey we have insurance. - || ($migrationInfo['rows'][$key]['main'] === '0' && substr($key, 0, 12) == 'move_custom_') - ) + ($migrationInfo['rows'][$key]['main'] !== '' && $migrationInfo['rows'][$key]['main'] !== NULL) && $migrationInfo['rows'][$key]['main'] != $migrationInfo['rows'][$key]['other'] ) { -- To view, visit https://gerrit.wikimedia.org/r/297342 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifed0b4d46ccece8193b3d64e9366389de6537cd3 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm/civicrm Gerrit-Branch: master Gerrit-Owner: Eileen <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
