Fork me on GitHub
Subscribe 2

Ticket #1098 (open bug)

Don't use local aware format for sprintf

  • Created: 2017-01-02 08:42:28
  • Reported by: Otomatic
  • Assigned to: None
  • 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.