X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FMagicWord.php;h=424735e51ba381365fa245c717383d241067a73f;hb=5262d41a6c35ad37b834a39059d650ebc348299a;hp=2c7ba91bf2bb0daa88aa3d3d6c4ec86575ee2d05;hpb=1b028a6c7491957bb336077fc14bf92d35aa7f73;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 2c7ba91bf2..424735e51b 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -941,6 +941,7 @@ class MagicWordArray { * * @param string $text * + * @throws Exception * @return array */ public function matchAndRemove( &$text ) { @@ -951,13 +952,22 @@ class MagicWordArray { continue; } $matches = array(); - if ( preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ) ) { + $matched = preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ); + if ( $matched === false ) { + throw new Exception( __METHOD__ . ': preg_match_all returned false' ); + } + if ( $matched ) { foreach ( $matches as $m ) { list( $name, $param ) = $this->parseMatch( $m ); $found[$name] = $param; } } - $text = preg_replace( $regex, '', $text ); + $replaced = preg_replace( $regex, '', $text ); + if ( $replaced !== null ) { + $text = $replaced; + } else { + throw new Exception( __METHOD__ . ': preg_replace returned null' ); + } } return $found; }