From: umherirrender Date: Thu, 10 Sep 2015 19:43:46 +0000 (+0200) Subject: Fix use of preg_match_all in MagicWord.php X-Git-Tag: 1.31.0-rc.0~9977^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=2a876978949749967d924585e47ad3d5aa133261 Fix use of preg_match_all in MagicWord.php Init variable before use Check return value to avoid notice on failures Change-Id: I5cecae32f7672d748706c7a72bf01e9aee65e6d4 --- diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 833f852715..2c7ba91bf2 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -950,10 +950,12 @@ class MagicWordArray { if ( $regex === '' ) { continue; } - preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ); - foreach ( $matches as $m ) { - list( $name, $param ) = $this->parseMatch( $m ); - $found[$name] = $param; + $matches = array(); + if ( preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ) ) { + foreach ( $matches as $m ) { + list( $name, $param ) = $this->parseMatch( $m ); + $found[$name] = $param; + } } $text = preg_replace( $regex, '', $text ); }