Advertisement:

Author Topic: Error Log is filed with numeric value errors  (Read 1770 times)

Offline Demidrin

  • Semi-Newbie
  • *
  • Posts: 16
Error Log is filed with numeric value errors
« on: June 13, 2017, 01:57:59 AM »
Hi everyone,

since the 2.0.14 update I have this kind of error (where UUU is a random user ID):

Code: [Select]
... index.php?action=profile;area=statistics;u=UUU
Apply Filter: Only show the errors with the same message
8: A non well formed numeric value encountered
Apply Filter: Only show the errors from this file
File: /.../Themes/default/GenericMenu.template.php (statPanel sub template - eval?)
Line: 1105

The stat page seems to load without display errors (I don't see anything not working).

Can you tell me, where I can find this in the code?
I want to have a look at it and maybe disable the line.

BR

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 60,233
  • Gender: Male
    • Kindred-999 on GitHub
Re: Error Log is filed with numeric value errors
« Reply #1 on: June 13, 2017, 06:20:50 AM »
please turn off eval? (server settings)
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 73,189
Re: Error Log is filed with numeric value errors
« Reply #2 on: June 13, 2017, 07:13:13 AM »
Why? The issue is Profile.template.php, line 1105...
No good deed goes unpunished
All helpful urges should be circumvented

Offline Demidrin

  • Semi-Newbie
  • *
  • Posts: 16
Re: Error Log is filed with numeric value errors
« Reply #3 on: June 13, 2017, 10:50:42 AM »
please turn off eval? (server settings)
Why? Does this forum doesn't support this? (I'm curious.)

Why? The issue is Profile.template.php, line 1105...
Thank you, I always looked into GenericMenu.template.php and wondered where the hell the line numbers are... :)

Offline Biology Forums

  • SMF Hero
  • ******
  • Posts: 3,778
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: Error Log is filed with numeric value errors
« Reply #4 on: June 13, 2017, 10:52:42 AM »
Is the problem fixed? You must have installed something accidentally that's mucking things up

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 73,189
Re: Error Log is filed with numeric value errors
« Reply #5 on: June 13, 2017, 10:56:55 AM »
Eval obfuscates where the real error is, but it's usually not hard to see where the real error can be found.
No good deed goes unpunished
All helpful urges should be circumvented

Offline Biology Forums

  • SMF Hero
  • ******
  • Posts: 3,778
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: Error Log is filed with numeric value errors
« Reply #6 on: June 13, 2017, 10:57:02 AM »
In addition, depending on the permissions given to you by your host, you could also look for core errors in the Apache error log, which pinpoint the exact errors.

Offline Demidrin

  • Semi-Newbie
  • *
  • Posts: 16
Re: Error Log is filed with numeric value errors
« Reply #7 on: June 13, 2017, 11:02:23 AM »
Is the problem fixed? You must have installed something accidentally that's mucking things up
Not yet, but I'm looking into it as soon as I have some time.

Eval obfuscates where the real error is, but it's usually not hard to see where the real error can be found.
I would like to understand the error/warning first, before I turn something off.

In addition, depending on the permissions given to you by your host, you could also look for core errors in the Apache error log, which pinpoint the exact errors.
It isn't my web space and apparently the error logs aren't activated.
If I can't figure it out, I'll ask for them. But so fare the code looks promising.

For the protocol: this is the line:
Code: [Select]
<div class="profile_pie" style="background-position: -', ((int) ($activity['percent'] / 5) * 20), 'px 0;" title="', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '">
I'll write a final note, as soon as I figured out the problem.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 73,189
Re: Error Log is filed with numeric value errors
« Reply #8 on: June 13, 2017, 11:09:27 AM »
What Kindred suggested won't fix anything at all. You saw yourself that the line being referred to in the error log was not correct, this is because the eval process causes it to be misreported. (No, this isn't a bug, it's the result of the design of how eval works. Eval is a safety net so that if a template is broken, SMF can catch it and issue a safe error page)

Does the user have posts? Do the little pie charts look logical for the user?
No good deed goes unpunished
All helpful urges should be circumvented

Offline Demidrin

  • Semi-Newbie
  • *
  • Posts: 16
Re: Error Log is filed with numeric value errors
« Reply #9 on: June 13, 2017, 11:25:05 AM »
What Kindred suggested won't fix anything at all. You saw yourself that the line being referred to in the error log was not correct, this is because the eval process causes it to be misreported. (No, this isn't a bug, it's the result of the design of how eval works. Eval is a safety net so that if a template is broken, SMF can catch it and issue a safe error page)
Ah, good to know.

Does the user have posts? Do the little pie charts look logical for the user?
The problem exists for all users (for all I tested at least).
The pie chart is off I think: For the example below: Only one board shown with the percentage of 0,11%.

And here are some sample value:
Code: [Select]
$activity['percent'] = 0,11
$activity['posts'] = 1
$activity['total_posts'] = 899
$activity['posts_percent'] = 0.1112
$txt['statPanel_topBoards_posts'] = %1$d Beitr├Ąge des Boards %2$d Beitr├Ąge (%3$01.2f%%)

As far as I know, the forum is pretty vanilla. Only in some boards the post counting is disabled via settings.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 73,189
Re: Error Log is filed with numeric value errors
« Reply #10 on: June 13, 2017, 11:28:29 AM »
Ok, it's confused by the fact that your activity value is 0,11 which the code cannot understand as being a number. PHP only understands . as the decimal point.

I wonder how it broke.
No good deed goes unpunished
All helpful urges should be circumvented

Offline Demidrin

  • Semi-Newbie
  • *
  • Posts: 16
Re: Error Log is filed with numeric value errors
« Reply #11 on: June 13, 2017, 11:32:49 AM »
I wonder how it broke.
Maybe a locale thing. Once it used the comma and the other time the point. Ours is a German forum, so comma is the German way of writing double values.

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,610
  • Gender: Male
    • i30 Owners Club
Re: Error Log is filed with numeric value errors
« Reply #12 on: June 13, 2017, 11:45:01 AM »
@Demidrin, have you recently upped your version of PHP?

I noticed a few of these errors appearing, once I'd raised my PHP level to above 5.6 (I'm on 7.1.5)

I'm wondering of there's been a tightening up of numeracy checks within PHP at the higher versions.

Offline Demidrin

  • Semi-Newbie
  • *
  • Posts: 16
Re: Error Log is filed with numeric value errors
« Reply #13 on: June 13, 2017, 11:47:20 AM »
@Demidrin, have you recently upped your version of PHP?

I noticed a few of these errors appearing, once I'd raised my PHP level to above 5.6 (I'm on 7.1.5)

I'm wondering of there's been a tightening up of numeracy checks within PHP at the higher versions.
Yes, we switch to PHP 7.1 too. I was just searching for this kind of errors in combination with PHP 7. :)

P.S.: I forgot to mention: I went back to PHP 5.6 and the error message is gone, but not the strange calculation of the pie chart.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 73,189
Re: Error Log is filed with numeric value errors
« Reply #14 on: June 13, 2017, 12:21:10 PM »
Maybe but that shouldn't be affecting internal calculations like that.

PHP is definitely more picky now, too, but this sounds like it's always been at least partially broken.
No good deed goes unpunished
All helpful urges should be circumvented

Offline Demidrin

  • Semi-Newbie
  • *
  • Posts: 16
Re: Error Log is filed with numeric value errors
« Reply #15 on: June 13, 2017, 12:24:45 PM »
Maybe but that shouldn't be affecting internal calculations like that.

PHP is definitely more picky now, too, but this sounds like it's always been at least partially broken.
Indeed, this is only the explanation why there are only now error messages.

I'll look into the root cause later, when I have time.

Offline Demidrin

  • Semi-Newbie
  • *
  • Posts: 16
Re: Error Log is filed with numeric value errors
« Reply #16 on: June 21, 2017, 01:27:18 PM »
Alright, it seems at least at my template there is a bug for default number format using commas in decimal numbers?

The current situation (line numbers may differ):
Profile.template.php (line 1099)
Code: [Select]
// Draw a bar for every board.
foreach ($context['board_activity'] as $activity)
{
echo '
<dt>', $activity['link'], '</dt>
<dd>
<div class="profile_pie" style="background-position: -', ((int) ($activity['percent'] / 5) * 20), 'px 0;" title="', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '">
', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '
</div>
<span>', $activity['percent'], '%</span>
</dd>';
}

And the calculation:
Profile-View.php (line 780):
Code: [Select]
$context['board_activity'][$row['id_board']] = array(
'id' => $row['id_board'],
'posts' => $row['message_count'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>',
'percent' => comma_format((float) $row['percentage'], 2),
'posts_percent' => (float) $row['percentage'],
'total_posts' => $row['num_posts'],
);

Value percent is with formatting (e.g. 38,20) and value posts_percent is without (e.g. 38.199).
As you can see above, the formatted value percent is used once for the template calculation.



I fixed this template part like this (using now the correct value for the calculation part):
Profile.template.php (line 1099)
Code: [Select]
// Draw a bar for every board.
foreach ($context['board_activity'] as $activity)
{
echo '
<dt>', $activity['link'], '</dt>
<dd>
<div class="profile_pie" style="background-position: -', ((int) ($activity['posts_percent'] / 5) * 20), 'px 0;" title="', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '">
', sprintf($txt['statPanel_topBoards_posts'], $activity['posts'], $activity['total_posts'], $activity['posts_percent']), '
</div>
<span>', $activity['percent'], '%</span>
</dd>';
}
That sprintf($txt['statPanel_topBoards_posts'],...) from my German translation still prints a point instead of a comma, but I don't care.

Maybe somebody can check if this is a general problem in the default template?

BR

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 73,189
Re: Error Log is filed with numeric value errors
« Reply #17 on: June 21, 2017, 01:47:20 PM »
It shouldn't need to change the sprintf part, just the line before.

But it is a problem with the default theme by the looks of it.
No good deed goes unpunished
All helpful urges should be circumvented

Offline FishingManMatt

  • Semi-Newbie
  • *
  • Posts: 67
  • Gender: Male
Re: Error Log is filed with numeric value errors
« Reply #18 on: November 19, 2019, 07:02:29 PM »
Hi!

Old topic, but I can confirm - after switching to PHP 7.1 I started getting the same log errors.
Just changed the code as Demidrin suggested and log errors are gone.