From e5ce1c5caa3cece226504e8e1c55109ed218901e Mon Sep 17 00:00:00 2001 From: Christian Wach Date: Thu, 4 Nov 2021 15:20:13 +0000 Subject: [PATCH] Repair the option value label for nb_NO language --- CRM/Upgrade/Incremental/php/FiveFortyFour.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CRM/Upgrade/Incremental/php/FiveFortyFour.php b/CRM/Upgrade/Incremental/php/FiveFortyFour.php index 2714f32b1e..54ed66aab5 100644 --- a/CRM/Upgrade/Incremental/php/FiveFortyFour.php +++ b/CRM/Upgrade/Incremental/php/FiveFortyFour.php @@ -62,6 +62,15 @@ class CRM_Upgrade_Incremental_php_FiveFortyFour extends CRM_Upgrade_Incremental_ $this->addTask('Add FK to civicrm_relationship_cache.case_id', 'addRelationshipCacheCaseFK'); } + /** + * Upgrade function. + * + * @param string $rev + */ + public function upgrade_5_44_beta1($rev) { + $this->addTask('Repair option value label for nb_NO', 'repairNBNOOptionValue'); + } + /** * @param \CRM_Queue_TaskContext $ctx * @return bool @@ -78,4 +87,24 @@ class CRM_Upgrade_Incremental_php_FiveFortyFour extends CRM_Upgrade_Incremental_ return TRUE; } + /** + * Repair the option value label for nb_NO language. + * + * @param CRM_Queue_TaskContext $ctx + */ + public static function repairNBNOOptionValue(CRM_Queue_TaskContext $ctx) { + // Repair the existing nb_NO entry. + $sql = CRM_Utils_SQL::interpolate('UPDATE civicrm_option_value SET label = @newLabel WHERE option_group_id = #group AND name = @name AND label IN (@oldLabels)', [ + 'name' => 'nb_NO', + 'newLabel' => ts('Norwegian Bokmål'), + // Adding check against old label in case they've customized it, in which + // case we don't want to overwrite that. The ts() part is tricky since + // it depends if they installed it in English first. + 'oldLabels' => ['Norwegian BokmÃ¥l', ts('Norwegian BokmÃ¥l')], + 'group' => CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_option_group WHERE name = "languages"'), + ]); + CRM_Core_DAO::executeQuery($sql); + return TRUE; + } + } -- 2.25.1