From: Antoine Musso Date: Tue, 11 Jul 2006 13:42:34 +0000 (+0000) Subject: Fix #6526: Undefined offset notice in MagicWord.php on bad input X-Git-Tag: 1.31.0-rc.0~56307 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=fd076f7b78971771393bb6b7c8dd5ff1303be9ea;p=lhc%2Fweb%2Fwiklou.git Fix #6526: Undefined offset notice in MagicWord.php on bad input Filter first, check after. --- diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 75a8413844..c5b75027fb 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -310,14 +310,16 @@ class MagicWord { $matchcount = preg_match( $this->getVariableStartToEndRegex(), $text, $matches ); if ( $matchcount == 0 ) { return NULL; - } elseif ( count($matches) == 1 ) { - return $matches[0]; } else { # multiple matched parts (variable match); some will be empty because of # synonyms. The variable will be the second non-empty one so remove any # blank elements and re-sort the indices. + # See also bug 6526 + $matches = array_values(array_filter($matches)); - return $matches[1]; + + if ( count($matches) == 1 ) { return $matches[0]; } + else { return $matches[1]; } } }