Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export minor refactor Move household relationship types to the processor #12579

Merged
merged 2 commits into from
Aug 14, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Jul 27, 2018

Overview

Code clean up on export : move static variables to the new OO processor class

Before

Code less maintainable

Uses

protected static $headOfHouseholdRelationshipKey;
protected static $memberOfHouseholdRelationshipKey;

After

Code more maintainable. Uses

$processor->getHouseholdRelationshipTypes()

Technical Details

This change is comprehensively covered by this test https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/CRM/Export/BAO/ExportTest.php#L421

@monishdeb when I went to enable the test I found it was a bit broken in the scenario covered by the test. I don't know how realistic is is but the test was requesting a household merge and additionally for household related fields to be returned. The code was deliberately unsetting the headers & sql columns inconsistently here. I updated so that the headers would never be set for household relationship types when merge to household is configured. This is a code simplification & consistent with what the code was trying to do. However, it's not 100% what the user would expect. I think this is a forwards rather than backwards step though.

Comments

Part of larger cleanup - current WIP is #12575

@civibot
Copy link

civibot bot commented Jul 27, 2018

(Standard links)

@eileenmcnaughton
Copy link
Contributor Author

test this please

@@ -1214,9 +1189,6 @@ public static function mergeSameHousehold($exportTempTable, &$headerRows, &$sqlC
foreach ($replaced as $from => $to) {
$clause[] = "$from = $to ";
unset($sqlColumns[$to]);
if ($key = CRM_Utils_Array::key($to, $allKeys)) {
unset($headerRows[$key]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colemanw
Copy link
Member

Makes sense; tests pass.

@colemanw colemanw merged commit f3baf55 into civicrm:master Aug 14, 2018
@colemanw colemanw deleted the export_another branch August 14, 2018 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants