From: Gergő Tisza Date: Thu, 29 Oct 2015 21:52:44 +0000 (-0700) Subject: Revert throwing exceptions on preg_* failures X-Git-Tag: 1.31.0-rc.0~9172^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=1b39760a3ab3dd88e1412f289392c69aeff99c6a;p=lhc%2Fweb%2Fwiklou.git Revert throwing exceptions on preg_* failures This reverts I3840a56adc0a6e50963b930051892491f8e90245 which threw exceptions on broken UTF-8 in $text. Bug: T115514 Bug: T117066 Change-Id: Ie665056a13f9e3678a49790d787b0a41dbba6362 --- diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 17c7cd4914..2c7ba91bf2 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -941,7 +941,6 @@ class MagicWordArray { * * @param string $text * - * @throws Exception * @return array */ public function matchAndRemove( &$text ) { @@ -952,24 +951,13 @@ class MagicWordArray { continue; } $matches = array(); - $matched = preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ); - if ( $matched === false ) { - throw new Exception( __METHOD__ . ': preg_match_all returned false with error code ' - . preg_last_error() ); - } - if ( $matched ) { + if ( preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ) ) { foreach ( $matches as $m ) { list( $name, $param ) = $this->parseMatch( $m ); $found[$name] = $param; } } - $replaced = preg_replace( $regex, '', $text ); - if ( $replaced !== null ) { - $text = $replaced; - } else { - throw new Exception( __METHOD__ . ': preg_replace returned null with error code ' - . preg_last_error() ); - } + $text = preg_replace( $regex, '', $text ); } return $found; }