Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“non well formed numeric value encountered” upon upgrading to 3.10 and php7.3 #14662

Closed
DeamonMV opened this issue Jul 17, 2019 · 7 comments · Fixed by #14901
Closed

“non well formed numeric value encountered” upon upgrading to 3.10 and php7.3 #14662

DeamonMV opened this issue Jul 17, 2019 · 7 comments · Fixed by #14901
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@DeamonMV
Copy link

DeamonMV commented Jul 17, 2019

What is my ENV:

VM server on Hetzner
Matomo version: 3.10.0
MySQL version: 5.7.26
PHP version: 7.3.6-1+0~20190531112735.39+stretch~1.gbp6131b7

What is a problem

Sometimes i get those warning

WARNING: /var/www/matomo/vendor/davaxi/sparkline/src/Sparkline/FormatTrait.php(193): Notice - A non well formed numeric value encountered```

@tsteur
Copy link
Member

tsteur commented Jul 17, 2019

@DeamonMV do you know if that happens when viewing a specific report or sparkline ?

@Kervinou
Copy link

Kervinou commented Sep 14, 2019

same issue for me, my new server use MariaDB last version on Debian Linux Buster with PHP 7.3.4-2

@MichaelRoosz
Copy link
Contributor

I did some research on this.
The problematic line is
$value = round(($value / $max) * $height);
$value should be fine because its value comes from some lines above: $value = (int)$value;
$height should be fine because it comes from getInnerNormalizedHeight() which does return $this->getInnerHeight() * $this->ratioComputing;, forcing it to be numerical
this leaves us with $max which comes from getMaxValue() with either returns $this->base which we never set or max($this->data);
So the offending value must be the max value $this->data which we set in Piwik\Visualization\Sparkline.

Thus, this warning most likely can be avoided by ensuring we only pass numerical values in the $sparkline->setData($values); call in Piwik\Visualization\Sparkline.

I will do some more research and come back if I can track it down some more.

@MichaelRoosz
Copy link
Contributor

MichaelRoosz commented Sep 19, 2019

I added some debug code to my setup:

if (!is_numeric($value)) {
    file_put_contents("debug.log.txt", var_export($value, true) . PHP_EOL, FILE_APPEND);
}

It found these values:

'78 '
'79,5 '
'81,63 '
'80,88 '
'84,05 '
'84,04 '
'81,37 '
'82,16 '
'75,38 '
'79,91 '
'82,33 '
'81,88 '
'83,38 '

The problem with these values is the space character at the end which makes them non-numerical for php.
To resolve the problem a simple trim() should do the trick.

While debugging I also found this code:

$thousandSeparator = Piwik::translate('Intl_NumberSymbolGroup');
$decimalSeparator = Piwik::translate('Intl_NumberSymbolGroup');
$value = str_replace($thousandSeparator, '', $value);
$value = str_replace($decimalSeparator, '.', $value);

Which makes no sense if both times "Intl_NumberSymbolGroup" is used, so I think it should be "Intl_NumberSymbolDecimal" for $decimalSeparator.

@MichaelRoosz
Copy link
Contributor

MichaelRoosz commented Sep 19, 2019

After thinking about it, I guess it would be good to fix the cause of the appended space character. I will debug some more, this time with a call trace. Maybe we also should check all values with is_numeric() and throw a more meaningful warning if it fails

@MichaelRoosz
Copy link
Contributor

My findings after some more debugging:

The problematic values come from "bounce_rate" and "funnel_conversion_rate" (and most likely all other percent values). The strings have the form '16 %', after removing the '%' the space was left at the end. My first pull reuquest added a trim($value) which successfully removed any normal spaces (and tabs). However while debugging I also got strings with "non-breaking" spaces, encoded in ISO/ASCII (hex 0xA0) as well as UTF-8 (hex 0xC2 0xA0).

I will create a new PR to solve this issue as well.

@mattab mattab modified the milestones: 3.13.0, 3.12.0 Oct 25, 2019
@Md-Maruf
Copy link

``$validation_code = md5($username . microtime());
I have used '.' but not working. do you have any more solution, please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants