Skip to content

Commit

Permalink
Merge pull request #16185 from seamuslee001/dev_core_711
Browse files Browse the repository at this point in the history
dev/core#711 Add in upgrade step for removing Google+ from website ty…
  • Loading branch information
eileenmcnaughton authored Jan 3, 2020
2 parents 910a22d + b490a58 commit e80b17e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 36 deletions.
32 changes: 29 additions & 3 deletions CRM/Upgrade/Incremental/php/FiveTwentyThree.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,34 @@ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
// // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable.
// }

// public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) {
// return TRUE;
// }
/**
* Upgrade function.
*
* @param string $rev
*/
public function upgrade_5_23_alpha1($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
$this->addTask('Remove Google + location option', 'removeGooglePlusOption');
}

/**
* Remove Google + option value option for website type
* only if there is no websites using it
*/
public static function removeGooglePlusOption(CRM_Queue_TaskContext $ctx) {
$googlePlusValue = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Website', 'website_type_id', 'Google_');
if ($googlePlusValue) {
$values = CRM_Core_DAO::executeQuery("SELECT * FROM civicrm_website WHERE website_type_id = %1", [1 => [$googlePlusValue, 'Positive']])->fetchAll();
if (empty($values)) {
$optionGroup = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_option_group WHERE name = 'website_type'");
\Civi\Api4\OptionValue::delete()
->addWhere('value', '=', $googlePlusValue)
->addWhere('option_group_id', '=', $optionGroup)
->setCheckPermissions(FALSE)
->execute();
}
}
return TRUE;
}

}
66 changes: 33 additions & 33 deletions sql/civicrm_generated.mysql

Large diffs are not rendered by default.

0 comments on commit e80b17e

Please sign in to comment.