From 9a894bf182ab100f6a3f5d93201d3cfdc137d397 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 11 Jun 2020 12:59:31 +1000 Subject: [PATCH] Add in depreation notice and status check for a money value format configuration other than the default Update to include issue link Update to use CRM_Core_Error::deprecated function and mention deprecation notice on settings page --- CRM/Utils/Check/Component/Schema.php | 15 +++++++++++++++ CRM/Utils/Money.php | 7 +++++++ templates/CRM/Admin/Form/Setting/Localization.tpl | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CRM/Utils/Check/Component/Schema.php b/CRM/Utils/Check/Component/Schema.php index 33eef62216..fe5da9a0cf 100644 --- a/CRM/Utils/Check/Component/Schema.php +++ b/CRM/Utils/Check/Component/Schema.php @@ -178,4 +178,19 @@ class CRM_Utils_Check_Component_Schema extends CRM_Utils_Check_Component { return $messages; } + public function checkMoneyValueFormatConfig() { + $messages = []; + if (CRM_Core_Config::singleton()->moneyvalueformat !== '%!i') { + $msg = new CRM_Utils_Check_Message( + __FUNCTION__, + ts('

The Money Value format stored is deprecated please report your configuration on Gitlab Issue'), + ts('Deprectad money value format configuration'), + \Psr\Log\LogLevel::WARNING, + 'fa-server' + ); + $messages[] = $msg; + } + return $messages; + } + } diff --git a/CRM/Utils/Money.php b/CRM/Utils/Money.php index bbe8072a25..551024153f 100644 --- a/CRM/Utils/Money.php +++ b/CRM/Utils/Money.php @@ -61,6 +61,10 @@ class CRM_Utils_Money { $valueFormat = $config->moneyvalueformat; } + if (!empty($valueFormat) && $valueFormat !== '%!i') { + CRM_Core_Error::deprecatedFunctionWarning('Having a Money Value format other than !%i is deprecated, please report this on the GitLab Issue https://lab.civicrm.org/dev/core/-/issues/1494 with the relevant moneyValueFormat you use.'); + } + if ($onlyNumber) { // money_format() exists only in certain PHP install (CRM-650) if (is_numeric($amount) and function_exists('money_format')) { @@ -170,6 +174,9 @@ class CRM_Utils_Money { * @return string */ protected static function formatLocaleNumeric($amount) { + if (CRM_Core_Config::singleton()->moneyvalueformat !== '%!i') { + CRM_Core_Error::deprecatedFunctionWarning('Having a Money Value format other than !%i is deprecated, please report this on GitLab with the relevant moneyValueFormat you use.'); + } return self::formatNumericByFormat($amount, CRM_Core_Config::singleton()->moneyvalueformat); } diff --git a/templates/CRM/Admin/Form/Setting/Localization.tpl b/templates/CRM/Admin/Form/Setting/Localization.tpl index c2e8529171..498e9f13a0 100644 --- a/templates/CRM/Admin/Form/Setting/Localization.tpl +++ b/templates/CRM/Admin/Form/Setting/Localization.tpl @@ -71,7 +71,7 @@ {$form.moneyvalueformat.label} {help id='moneyvalueformat' title=$form.moneyvalueformat.label} - {$form.moneyvalueformat.html} + {$form.moneyvalueformat.html}
Note that this setting is proposed to be deprecated as per this Gitlab Issue {$form.customTranslateFunction.label} {help id='customTranslateFunction' title=$form.customTranslateFunction.label} -- 2.25.1