From 906a73e2e0560324d14aee432f93a797df655375 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 9 Apr 2020 14:41:08 -0700 Subject: [PATCH] dev/translation#4 - Refine upgrade steps for modifying nl_NL 1. This adds a filter on `option_group_id` so that we don't modify unrelated OGs/OVs 2. Use simpler SQL semantics per https://docs.civicrm.org/dev/en/latest/framework/upgrade/#tips-prefer-simple-sql-semantics-over-apibaodao --- CRM/Upgrade/Incremental/php/FiveTwentySix.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/FiveTwentySix.php b/CRM/Upgrade/Incremental/php/FiveTwentySix.php index 9a1ed1adf2..1980c9e3b9 100644 --- a/CRM/Upgrade/Incremental/php/FiveTwentySix.php +++ b/CRM/Upgrade/Incremental/php/FiveTwentySix.php @@ -79,16 +79,16 @@ class CRM_Upgrade_Incremental_php_FiveTwentySix extends CRM_Upgrade_Incremental_ 'is_active' => 1, ]); // Update the existing nl_NL entry. - \Civi\Api4\OptionValue::update() - ->addWhere('name', '=', 'nl_NL') - // Adding check against label in case they've customized it, in which + $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' => 'nl_NL', + 'newLabel' => ts('Dutch (Netherlands)'), + // 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. - ->addClause('OR', ['label', '=', 'Dutch'], ['label', '=', ts('Dutch')]) - ->addValue('label', ts('Dutch (Netherlands)')) - ->setLimit(1) - ->setCheckPermissions(FALSE) - ->execute(); + 'oldLabels' => ['Dutch', ts('Dutch')], + 'group' => CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_option_group WHERE name = "languages"'), + ]); + CRM_Core_DAO::executeQuery($sql); return TRUE; } -- 2.25.1