Page MenuHomePhabricator

PHP Error "non-numeric value encountered" in CoreParserFunctions if padleft/padright have invalid length values
Closed, ResolvedPublic

Description

I'm running

ProductVersion
MediaWiki1.29.1
PHP7.1.10 (apache2handler)
MySQL5.6.38
ICU59.1

Each time I run maintenance/refreshLinks.php, I get this error a few times. (I removed some of the path for privacy reasons.)

Warning: A non-numeric value encountered in /includes/parser/CoreParserFunctions.php on line 901

Line 901 in 1.29, part of CoreParserFunctions::pad():

		$length = min( $length, 500 ) - mb_strlen( $string );

It occurs at between lines 4700 and 4800 and between lines 12300 and 12400.

I did some research on this error. Apparently, it's related to php7.1. I found this discussion on Github - https://github.com/dompdf/dompdf/issues/1272 that seems to indicate the use of arbitrary string values was previously silently cast to the number 0 if used in a mathematical expression, but as of PHP 7.1 is considered an error. In Dompdf this happened with the css sting "auto". Perhaps the use of "null" instead of 0 happens here.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 13 2017, 8:48 PM
Reedy moved this task from Unsorted to PHP 7.1 on the [DO NOT USE] NewPHP board.Dec 7 2017, 11:06 PM
Krinkle renamed this task from Parsing errors running maintenance/refreshLinks.php to PHP Error "non-numeric value encountered" from CoreParserFunctions when running maintenance/refreshLinks.php.Jun 10 2018, 12:28 AM
Krinkle renamed this task from PHP Error "non-numeric value encountered" from CoreParserFunctions when running maintenance/refreshLinks.php to PHP Error "non-numeric value encountered" in CoreParserFunctions from refreshLinks.php.
Krinkle updated the task description. (Show Details)Jun 10 2018, 12:33 AM
RazeSoldier moved this task from Backlog to Core on the MW-1.31-release board.Jun 10 2018, 5:12 AM
Legoktm updated the task description. (Show Details)Jun 10 2018, 5:41 PM
Legoktm claimed this task.Jun 10 2018, 5:46 PM

Change 439497 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@master] parser: Validate $length in padleft/padright parser functions

https://gerrit.wikimedia.org/r/439497

Legoktm renamed this task from PHP Error "non-numeric value encountered" in CoreParserFunctions from refreshLinks.php to PHP Error "non-numeric value encountered" in CoreParserFunctions if padleft/padright have invalid length values.Jun 10 2018, 6:21 PM

Change 439497 merged by jenkins-bot:
[mediawiki/core@master] parser: Validate $length in padleft/padright parser functions

https://gerrit.wikimedia.org/r/439497

Change 439802 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@REL1_31] parser: Validate $length in padleft/padright parser functions

https://gerrit.wikimedia.org/r/439802

Change 439804 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@REL1_30] parser: Validate $length in padleft/padright parser functions

https://gerrit.wikimedia.org/r/439804

Change 439805 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@REL1_29] parser: Validate $length in padleft/padright parser functions

https://gerrit.wikimedia.org/r/439805

Change 439806 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@REL1_27] parser: Validate $length in padleft/padright parser functions

https://gerrit.wikimedia.org/r/439806

Change 439802 merged by jenkins-bot:
[mediawiki/core@REL1_31] parser: Validate $length in padleft/padright parser functions

https://gerrit.wikimedia.org/r/439802

Change 439805 merged by jenkins-bot:
[mediawiki/core@REL1_29] parser: Validate $length in padleft/padright parser functions

https://gerrit.wikimedia.org/r/439805

Change 439806 merged by jenkins-bot:
[mediawiki/core@REL1_27] parser: Validate $length in padleft/padright parser functions

https://gerrit.wikimedia.org/r/439806

Change 439804 merged by jenkins-bot:
[mediawiki/core@REL1_30] parser: Validate $length in padleft/padright parser functions

https://gerrit.wikimedia.org/r/439804

Legoktm closed this task as Resolved.Jun 12 2018, 1:57 AM

Merged and backported to all supported stable releases.