[MediaWiki-commits] [Gerrit] wikimedia...crm[master]: Last change introduced an error when no address conflict exits

2017-10-09 Thread Eileen (Code Review)
Eileen has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/383295 )

Change subject: Last change introduced an error when no address conflict exits
..


Last change introduced an error when no address conflict exits

e.g hitting error on 
civicrm/contact/merge?reset=1=3986284=4244149=update=13={}=5=288

Bug T176699

Change-Id: I438fe2dd9f86b1a2a49fe7119ecb0656e04e3c4f
---
M sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
2 files changed, 27 insertions(+), 0 deletions(-)

Approvals:
  jenkins-bot: Verified
  Ejegg: Looks good to me, approved



diff --git a/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php 
b/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
index 9066984..f295002 100644
--- a/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
+++ b/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
@@ -735,6 +735,29 @@
   }
 
   /**
+   * Test that we still cope when there is no address conflict
+   *
+   * Bug T176699
+   */
+  public function 
testBatchMergeNoRealConflictOnAddressButAnotherConflictResolved() {
+$this->callAPISuccess('Address', 'create', array(
+  'contact_id' => $this->contactID2,
+  'country' => 'Korea, Republic of',
+  'location_type_id' => 1,
+));
+$this->callAPISuccess('Address', 'create', array(
+  'contact_id' => $this->contactID,
+  'country' => 'Korea, Republic of',
+  'location_type_id' => 1,
+));
+$this->contributionCreate(array('contact_id' => $this->contactID, 
'receive_date' => '2010-01-01', 'total_amount' => 500));
+
+$result = $this->callAPISuccess('Job', 'process_batch_merge', array('mode' 
=> 'safe'));
+$this->assertEquals(0, count($result['values']['skipped']));
+$this->assertEquals(1, count($result['values']['merged']));
+  }
+
+  /**
* Test that we don't see a city named after a country as the same as a 
country
* when it has no country.
*
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index 17233c8..5fc5076 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -4043,6 +4043,10 @@
 $keysToIgnore = array('id', 'is_primary', 'is_billing', 'manual_geo_code', 
'contact_id', 'reset_date', 'hold_date', 'display', 'location_type_id');
 $comparisonAddress = array_diff_key($comparisonAddress, 
array_flip($keysToIgnore));
 $mainAddress = array_diff_key($mainAddress, array_flip($keysToIgnore));
+if ($mainAddress === $comparisonAddress) {
+  // They are the same... which to choose, which to choose :-)
+  return FALSE;
+}
 if (count($comparisonAddress) === 1
   && !empty($comparisonAddress['country_id'])
   && !empty($mainAddress['country_id'])

-- 
To view, visit https://gerrit.wikimedia.org/r/383295
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I438fe2dd9f86b1a2a49fe7119ecb0656e04e3c4f
Gerrit-PatchSet: 2
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen 
Gerrit-Reviewer: Eileen 
Gerrit-Reviewer: Ejegg 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] wikimedia...crm[master]: Last change introduced an error when no address conflict exits

2017-10-09 Thread Eileen (Code Review)
Eileen has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383295 )

Change subject: Last change introduced an error when no address conflict exits
..

Last change introduced an error when no address conflict exits

e.g hitting error on 
civicrm/contact/merge?reset=1=3986284=4244149=update=13={}=5=288

Bug T176699

Change-Id: I438fe2dd9f86b1a2a49fe7119ecb0656e04e3c4f
---
M sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
2 files changed, 29 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/95/383295/1

diff --git a/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php 
b/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
index 9066984..baf4082 100644
--- a/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
+++ b/sites/all/modules/wmf_civicrm/tests/phpunit/MergeTest.php
@@ -735,6 +735,31 @@
   }
 
   /**
+   * Test that we still cope when there is no address conflict
+   *
+   * Bug T176699
+   */
+  public function 
testBatchMergeNoRealConflictOnAddressButAnotherConflictResolved() {
+$this->callAPISuccess('Address', 'create', array(
+  'contact_id' => $this->contactID2,
+  'country' => 'Korea, Republic of',
+  'location_type_id' => 1,
+  'first_name' => 'Two words',
+));
+$this->callAPISuccess('Address', 'create', array(
+  'contact_id' => $this->contactID,
+  'country' => 'Korea, Republic of',
+  'location_type_id' => 1,
+  'first_name' => 'twowords',
+));
+$this->contributionCreate(array('contact_id' => $this->contactID, 
'receive_date' => '2010-01-01', 'total_amount' => 500));
+
+$result = $this->callAPISuccess('Job', 'process_batch_merge', array('mode' 
=> 'safe'));
+$this->assertEquals(0, count($result['values']['skipped']));
+$this->assertEquals(1, count($result['values']['merged']));
+  }
+
+  /**
* Test that we don't see a city named after a country as the same as a 
country
* when it has no country.
*
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index 17233c8..5fc5076 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -4043,6 +4043,10 @@
 $keysToIgnore = array('id', 'is_primary', 'is_billing', 'manual_geo_code', 
'contact_id', 'reset_date', 'hold_date', 'display', 'location_type_id');
 $comparisonAddress = array_diff_key($comparisonAddress, 
array_flip($keysToIgnore));
 $mainAddress = array_diff_key($mainAddress, array_flip($keysToIgnore));
+if ($mainAddress === $comparisonAddress) {
+  // They are the same... which to choose, which to choose :-)
+  return FALSE;
+}
 if (count($comparisonAddress) === 1
   && !empty($comparisonAddress['country_id'])
   && !empty($mainAddress['country_id'])

-- 
To view, visit https://gerrit.wikimedia.org/r/383295
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I438fe2dd9f86b1a2a49fe7119ecb0656e04e3c4f
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits