Skip to content

Commit

Permalink
Add upgrade to remove bad address data
Browse files Browse the repository at this point in the history
Bug: T328369
Change-Id: I5b2f3973f9b797e081306e9ac1ccdcbd20afc3c4
  • Loading branch information
eileenmcnaughton committed Feb 9, 2023
1 parent 541f4ed commit f334103
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,21 @@ public function upgrade_4222(): bool {
return TRUE;
}

/**
* Remove unused option values.
*
* @return true
*/
public function upgrade_4230(): bool {
CRM_Core_DAO::executeQuery(
"UPDATE civicrm_address
SET street_address = NULL
WHERE street_address IN
('" . implode("','", $this->getBadStrings()) . "')"
);
return TRUE;
}

/**
* Get the values actually used for the option.
*
Expand All @@ -729,4 +744,31 @@ private function getInUseOptions(string $field): array {
return $usedOptions;
}

/**
* Get strings that can be considered non-data in street address.
*
* @return string[]
*/
protected function getBadStrings(): array {
return [
'n/a',
'123 Fake Street',
'A',
'Anonymous',
'C',
'X',
'NA',
'xxx',
'z',
'1',
'3',
'Q',
'r',
'aa',
'k',
'asd',
'w',
];
}

}

0 comments on commit f334103

Please sign in to comment.