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 created this task.Oct 14 2015, 8:32 PM
Legoktm updated the task description. (Show Details)
Legoktm raised the priority of this task from to Needs Triage.
Legoktm claimed this task.
Legoktm added a project: MediaWiki-Parser.
Legoktm added subscribers: Legoktm, ori.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 14 2015, 8:32 PM

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

Tgr added subscribers: Bawolff, Tgr.Oct 29 2015, 11:05 PM

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

Tgr added a comment.Oct 30 2015, 12:57 AM

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 closed this task as Resolved.Nov 2 2015, 6:12 PM
Legoktm reassigned this task from Legoktm to Tgr.