Cleanup for r53518 (subpage support for edit comments)
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 21 Jul 2009 17:07:56 +0000 (17:07 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 21 Jul 2009 17:07:56 +0000 (17:07 +0000)
Reported bug: PHP Notice: Undefined variable: thelink in /var/www/w/includes/Linker.php on line 1090 on hitting http://translatewiki.net/w/i.php?title=Special:Log&dir=prev&user=Siebrand
Weren't properly checking for the case where we end up with an invalid link at the end.

includes/Linker.php

index b88ec1a..bcd23a7 100644 (file)
@@ -1053,6 +1053,7 @@ class Linker {
                        $text = $match[1];
                }
                $submatch = array();
+               $thelink = null;
                if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
                        # Media link; trail not supported.
                        $linkRegexp = '/^(.*?)\]\]/';
@@ -1087,7 +1088,10 @@ class Linker {
                                ) . $trail;
                        }
                }
-               $comment = preg_replace( $linkRegexp, StringUtils::escapeRegexReplacement( $thelink ), $comment, 1 );
+               if( $thelink ) {
+                       // If the link is still valid, go ahead and replace it in!
+                       $comment = preg_replace( $linkRegexp, StringUtils::escapeRegexReplacement( $thelink ), $comment, 1 );
+               }
 
                return $comment;
        }