Fork me on GitHub
Subscribe 2

Ticket #1098 (fixed bug)

Don't use local aware format for sprintf

  • Created: 2017-01-02 08:42:28
  • Reported by: Otomatic
  • Assigned to: Franz
  • Milestone: 1.5.11
  • Component: code
  • Priority: normal

Do not use "sprintf" formats that depend on locales.
For example, in the file "forum\include\dblayer\mysqli.php"

$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));

With a locale fr_FR gives floating values with a comma instead of a period:
0,00256 au lieu de 0.00256

One must use "F", not "f":
$this->saved_queries[] = array($sql, sprintf('%.5F', get_microtime() - $q_start));

Note: Problem only visible in "PUN_SHOW_QUERIES" mode


Franz 2017-01-05 21:44:42

But isn't that what you want when all the strings are in French as well? I feel like I'm misunderstanding something, sorry. wink

Otomatic 2017-01-06 08:46:17

Yes it is what I want. But not for saved queries because the calculation of the total time gives an error if number are not float type.

Franz 2017-01-06 19:36:16

  • Milestone set to 1.5.11.

Ah, gotcha, thanks for the explanation.

Franz 2018-01-13 09:22:21

  • Owner set to Franz.
  • Status changed from open to fixed.

Commit 1a31a2e to fluxbb master

Store query times independent of locale setting

Formatting for floats in other languages might be different,
causing different representations which then break the
calculations (for query time).

This requires at least PHP 4.3.10 or 5.0.3.

Fixes #1098.