X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FMagicWord.php;h=80e60d2a34acdd3252e519fbab98327e441be617;hb=b8dc00872d328c796b12ce768ff14f5c5a04809b;hp=2c7ba91bf2bb0daa88aa3d3d6c4ec86575ee2d05;hpb=8aafaa30dfc52cfad806f6ad0da32b78ca473704;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 2c7ba91bf2..80e60d2a34 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -23,6 +23,8 @@ * @ingroup Parser */ +use MediaWiki\Logger\LoggerFactory; + /** * This class encapsulates "magic words" such as "#redirect", __NOTOC__, etc. * @@ -951,13 +953,28 @@ class MagicWordArray { continue; } $matches = array(); - if ( preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ) ) { + $res = preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ); + if ( $res === false ) { + LoggerFactory::getInstance( 'parser' )->warning( 'preg_match_all returned false', array( + 'code' => preg_last_error(), + 'regex' => $regex, + 'text' => $text, + ) ); + } elseif ( $res ) { foreach ( $matches as $m ) { list( $name, $param ) = $this->parseMatch( $m ); $found[$name] = $param; } } - $text = preg_replace( $regex, '', $text ); + $res = preg_replace( $regex, '', $text ); + if ( $res === null ) { + LoggerFactory::getInstance( 'parser' )->warning( 'preg_replace returned null', array( + 'code' => preg_last_error(), + 'regex' => $regex, + 'text' => $text, + ) ); + } + $text = $res; } return $found; }