Page MenuHomePhabricator

MagicWord.php should check return value of preg_* calls
Closed, ResolvedPublic

Description

in MagicWord::matchAndRemove():

			$text = preg_replace( $regex, '', $text );

if preg_replace errors, it will log a warning and then return null. At some point, $text will be cast to an empty string. We should throw an exception if it errors, instead of silently failing.

Related: https://wikitech.wikimedia.org/wiki/Incident_documentation/20151014-MediaWiki

Event Timeline

Legoktm claimed this task.
Legoktm raised the priority of this task from to Needs Triage.
Legoktm updated the task description. (Show Details)
Legoktm added a project: MediaWiki-Parser.
Legoktm added subscribers: Legoktm, ori.

Change 246719 had a related patch set uploaded (by Legoktm):
Throw Exceptions on preg_* failures in MagicWordArray::matchAndRemove()

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

Change 246719 merged by jenkins-bot:
Throw Exceptions on preg_* failures in MagicWordArray::matchAndRemove()

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

Change 249873 had a related patch set uploaded (by Gergő Tisza):
Include preg_last_error() in error message when preg_* fails

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

Change 249873 merged by jenkins-bot:
Include preg_last_error() in error message when preg_* fails

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

Change 249888 had a related patch set uploaded (by Gergő Tisza):
Include preg_last_error() in error message when preg_* fails

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

Change 249888 merged by jenkins-bot:
Include preg_last_error() in error message when preg_* fails

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

Change 249898 had a related patch set uploaded (by Gergő Tisza):
Revert throwing exceptions on preg_* failures

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

Change 249901 had a related patch set uploaded (by Gergő Tisza):
Revert throwing exceptions on preg_* failures

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

Change 249898 merged by jenkins-bot:
Revert throwing exceptions on preg_* failures

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

Change 249901 merged by jenkins-bot:
Revert throwing exceptions on preg_* failures

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

Reverted due to T117066 (according to @Bawolff the errors come from file metadata). Will add logging instead.

Change 249942 had a related patch set uploaded (by Gergő Tisza):
Log warnings on on preg_* failures in MagicWordArray::matchAndRemove()

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

The bug that triggered the exceptions is T117129.

Change 249942 merged by jenkins-bot:
Log warnings on on preg_* failures in MagicWordArray::matchAndRemove()

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

Legoktm reassigned this task from Legoktm to Tgr.