Fix bug #28642 - wrong part->commentEnd set to abbutting comments
authorMark A. Hershberger <mah@users.mediawiki.org>
Thu, 21 Apr 2011 22:20:48 +0000 (22:20 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Thu, 21 Apr 2011 22:20:48 +0000 (22:20 +0000)
    To be able to search for headline-closing equal sign even when
    there are comments between the last = and the linebreak, there are
    some position values appended to the recent domParts. This works
    well with the first comment, but as soon as a second one comes,
    the commentEnd value is set to $wsEnd instead of $endPos.

Patch from Bergi

includes/parser/Preprocessor_DOM.php

index 2587510..907cbd0 100644 (file)
@@ -343,13 +343,11 @@ class Preprocessor_DOM implements Preprocessor {
 
                                                if ( $stack->top ) {
                                                        $part = $stack->top->getCurrentPart();
-                                                       if ( isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 ) {
-                                                               // Comments abutting, no change in visual end
-                                                               $part->commentEnd = $wsEnd;
-                                                       } else {
+                                                       $part->commentEnd = $endPos;
+                                                       if ( ! (isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 )) {
                                                                $part->visualEnd = $wsStart;
-                                                               $part->commentEnd = $endPos;
                                                        }
+                                                       // Else comments abutting, no change in visual end
                                                }
                                                $i = $endPos + 1;
                                                $inner = substr( $text, $startPos, $endPos - $startPos + 1 );