From 369f767c0160f9fd87a06523362553357e18050c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 21 Jul 2009 17:07:56 +0000 Subject: [PATCH] Cleanup for r53518 (subpage support for edit comments) 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/Linker.php b/includes/Linker.php index b88ec1a402..bcd23a7a20 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -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; } -- 2.20.1