Advertisement:

Author Topic: A non-numeric value encountered  (Read 3798 times)

Offline inter

  • Jr. Member
  • **
  • Posts: 290
  • Gender: Male
    • interlab on GitHub
A non-numeric value encountered
« on: February 15, 2018, 02:49:44 AM »
php 7.1
smf 2.015
Url: http://.../index.php?action=recent;start=%1$d
Error: A non-numeric value encountered
File: /.../Sources/Recent.php
Line: 229
Sorry for my English

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,073
  • Gender: Male
    • i30 Owners Club
Re: A non-numeric value encountered
« Reply #1 on: February 15, 2018, 02:50:58 AM »
Was this from a Tapatalk user/IP or a 66.249.* Google bot by any chance?

Offline inter

  • Jr. Member
  • **
  • Posts: 290
  • Gender: Male
    • interlab on GitHub
Re: A non-numeric value encountered
« Reply #2 on: February 15, 2018, 02:52:55 AM »
Was this from a Tapatalk user/IP or a 66.249.* Google bot by any chance?
http://whois.arin.net/rest/ip/66.249.64.77
Sorry for my English

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,073
  • Gender: Male
    • i30 Owners Club
Re: A non-numeric value encountered
« Reply #3 on: February 15, 2018, 03:06:21 AM »
Have you recently upgraded your PHP from < 7.1?

From 7.1 upwards these non-numeric errors are tracked more vigorously and reported more often. I find the GoogleBots and Tapatalk members cause 99% of the errors you reported. Just ignore them (there's not much you can do anyway!)

Quote
New E_WARNING and E_NOTICE errors have been introduced when invalid strings are coerced using operators expecting numbers or their assignment equivalents. An E_NOTICE is emitted when the string begins with a numeric value but contains trailing non-numeric characters, and an E_WARNING is emitted when the string does not contain a numeric value.

https://stackoverflow.com/questions/42044127/warning-a-non-numeric-value-encountered

http://php.net/manual/en/migration71.other-changes.php

Offline inter

  • Jr. Member
  • **
  • Posts: 290
  • Gender: Male
    • interlab on GitHub
Re: A non-numeric value encountered
« Reply #4 on: February 15, 2018, 03:19:58 AM »
I reported an error, whether it will be corrected by the developers of the forum - this is already a question for them, not for me.
Sorry for my English

Offline live627

  • Developer
  • SMF Hero
  • *
  • Posts: 5,564
  • Gender: Male
    • live627 on Facebook
    • live627 on GitHub
    • live627 on LinkedIn
    • @live627 on Twitter
    • livemods
Re: A non-numeric value encountered
« Reply #5 on: October 30, 2018, 07:28:30 PM »
The line in question is

Code: [Select]
$query_parameters['max_id_msg'] = max(0, $modSettings['maxMsgID'] - 100 - $_REQUEST['start'] * 6);
The problem is immediately apparent: an unsanitized string is used in integer arithmetic (subtraction)

This isn't isolated, either...
Try not to become a man of success, but rather try to become a man of value.
- Albert Einstein

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,073
  • Gender: Male
    • i30 Owners Club
Re: A non-numeric value encountered
« Reply #6 on: October 30, 2018, 07:53:19 PM »
Quote from: live627
The problem is immediately apparent: an unsanitized string is used in integer arithmetic (subtraction)

Errr.. yes indeed.  Why bump such an old thread with an obvious diagnosis?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,509
    • StoryBB/StoryBB on GitHub
Re: A non-numeric value encountered
« Reply #7 on: October 31, 2018, 03:03:13 AM »
$_REQUEST['start'] isn’t unsanitised though. It’s actually more likely the modSettings entry...
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Aleksi "Lex" Kilpinen

  • A Peculiar Finn
  • Lead Support Specialist
  • SMF Super Hero
  • *
  • Posts: 18,031
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • LexArma on GitHub
    • aleksi-kilpinen on LinkedIn
    • There's No Place Like 127.0.0.1
Re: A non-numeric value encountered
« Reply #8 on: November 10, 2018, 06:59:34 AM »
Quote from: live627
The problem is immediately apparent: an unsanitized string is used in integer arithmetic (subtraction)

Errr.. yes indeed.  Why bump such an old thread with an obvious diagnosis?
Because going through bug reports is part of being a developer?
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.

How you can help SMF

"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum.
 Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Full Member
  • *
  • Posts: 624
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: A non-numeric value encountered
« Reply #9 on: November 10, 2018, 03:09:20 PM »
$_REQUEST['start'] isn’t unsanitised though. It’s actually more likely the modSettings entry...

If it were the $modSettings value, one would expect the error to occur every time, but the original report doesn't say anything to suggest that that's what was happening. So I expect live627's diagnosis is correct. My main question is whether this can be reproduced on a standard install or if it could be due to a mod that broke the sanitization somehow.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,509
    • StoryBB/StoryBB on GitHub
Re: A non-numeric value encountered
« Reply #10 on: November 10, 2018, 03:21:39 PM »
An unmodified QueryString.php file should be sanitising that value every time precisely because of the various ways it’s used...
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Full Member
  • *
  • Posts: 624
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: A non-numeric value encountered
« Reply #11 on: November 11, 2018, 10:04:36 PM »
A fix for this bug has been added for 2.0.16.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.