From 2a876978949749967d924585e47ad3d5aa133261 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Thu, 10 Sep 2015 21:43:46 +0200 Subject: [PATCH] Fix use of preg_match_all in MagicWord.php Init variable before use Check return value to avoid notice on failures Change-Id: I5cecae32f7672d748706c7a72bf01e9aee65e6d4 --- includes/MagicWord.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 ); } -- 2.20.1