Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Translation Translation
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 31
    • Issues 31
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • TranslationTranslation
  • Issues
  • #65
Closed
Open
Created Feb 02, 2021 by eileen@eileen🎱Owner

Remove legacy php money_format use, switch to brickmoney

Php 7.4 deprecated the money_format function and we need to move off it to fully support php 7.4 (which we are priortising now). We chose brickmoney as the replacement library.

The main usage is in the CRM_Utils_Money::format() library - this function has a lot of alternate functions depending on input params and we have been working to use more specific functions

I think in the end the main format function would support 3 parameters

  • amount (as a float or number)
  • currency (as a string)
  • use site separators (bool)

The first 2 are pretty straight forward. The latter is the idea that if you are looking at a table of donations you want consistent thousand & decimal separators, currency independent. But if you are presenting data front end you want the selection of Norwegian Kroner to also trigger a switch to appropriate formatting on the page

Some discrete steps we can take are

  1. instead of calling the function with the only number param call the inner function directly
  if ($onlyNumber) {
      $amount = self::formatLocaleNumericRoundedByCurrency($amount, $currency);
      return $amount;
    }
  1. do the same for calls that pass $format = '%a' - which has the same impact. (if currency is unknown formatLocaleNumericRoundedByPrecision is an option)

  2. fully remove / hard-code the deprecated $moneyValueFormat setting and parameter

if (CRM_Core_Config::singleton()->moneyvalueformat !== '%!i') {
 CRM_Core_Error::deprecatedWarning('Having a Money Value format other than !%i is deprecated, please report this on GitLab with the relevant moneyValueFormat you use.');
}
  1. actually replace the call to money_format.....
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking