Fix use of preg_match_all in MagicWord.php

Init variable before use
Check return value to avoid notice on failures

Change-Id: I5cecae32f7672d748706c7a72bf01e9aee65e6d4
This commit is contained in:
umherirrender 2015-09-10 21:43:46 +02:00
parent 6cf823b5cd
commit 2a87697894

View file

@ -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 );
}