From: Brion Vibber Date: Tue, 21 Jul 2009 17:07:56 +0000 (+0000) Subject: Cleanup for r53518 (subpage support for edit comments) X-Git-Tag: 1.31.0-rc.0~40783 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=369f767c0160f9fd87a06523362553357e18050c;p=lhc%2Fweb%2Fwiklou.git 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. --- 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; }