Fixes for r62505:
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 22 Feb 2010 07:02:12 +0000 (07:02 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 22 Feb 2010 07:02:12 +0000 (07:02 +0000)
* In MagicWordArray::matchStartAndRemove(), fixed the case where the length of localised synonym is not precisely the length of the magic word ID plus one
* Fixed the case where matchStartAndRemove() removes the entire string, send empty string not false
* Fix brace style

includes/MagicWord.php
includes/parser/Parser.php

index ecbdf81..d741832 100644 (file)
@@ -719,11 +719,14 @@ class MagicWordArray {
                        if ( $regex === '' ) {
                                continue;
                        }
-                       preg_match( $regex, $text, $match );
-                       if ( $match ) {
-                               list( $found, $param ) = $this->parseMatch( $match );
-                               $text = substr( $text, strlen( $found ) + 1 );
-                               return $found;
+                       if ( preg_match( $regex, $text, $m ) ) {
+                               list( $id, $param ) = $this->parseMatch( $m );
+                               if ( strlen( $m[0] ) >= strlen( $text ) ) {
+                                       $text = '';
+                               } else {
+                                       $text = substr( $text, strlen( $m[0] ) );
+                               }
+                               return $id;
                        }
                }
                return false;
index aa90132..06d4ac5 100644 (file)
@@ -2793,8 +2793,7 @@ class Parser
 
                        # Possibilities for substMatch: "subst", "safesubst" or FALSE
                        # Decide whether to expand template or keep wikitext as-is.
-                       if ( $this->ot['wiki'] )
-                       {
+                       if ( $this->ot['wiki'] ) {
                                if ( $substMatch === false ) {
                                        $literal = true;  # literal when in PST with no prefix
                                } else {