From 6e3edf5bee261b36599a02265921c526a6e59b55 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 13 Jan 2006 19:58:23 +0000 Subject: [PATCH] * Linker::formatComment corrupted the passed title object on PHP 5 if the comment included a section link. Use clone() to make a safe copy. --- RELEASE-NOTES | 2 ++ includes/Linker.php | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f76979ae9d..54891e6c9d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -479,6 +479,8 @@ fully support the editing toolbar, but was found to be too confusing. content loading and viewing, for clarity and consistency. * (bug 4104) 'OutputPageBeforeHTML' hook to postprocess article HTML on page view (comes after parser cache, if used). Patch by ThomasV. +* Linker::formatComment corrupted the passed title object on PHP 5 + if the comment included a section link. Use clone() to make a safe copy. === Caveats === diff --git a/includes/Linker.php b/includes/Linker.php index bfe45eb9ba..ffe062e354 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -663,7 +663,7 @@ class Linker { * comments. It escapes any HTML in the comment, but adds some CSS to format * auto-generated comments (from section editing) and formats [[wikilinks]]. * - * The &$title parameter must be a title OBJECT. It is used to generate a + * The $title parameter must be a title OBJECT. It is used to generate a * direct link to the section in the autocomment. * @author Erik Moeller * @@ -688,14 +688,15 @@ class Linker { $auto=$match[2]; $post=$match[3]; $link=''; - if($title) { - $section=$auto; + if( $title ) { + $section = $auto; # This is hackish but should work in most cases. - $section=str_replace('[[','',$section); - $section=str_replace(']]','',$section); - $title->mFragment=$section; - $link=$this->makeKnownLinkObj($title,wfMsg('sectionlink')); + $section = str_replace( '[[', '', $section ); + $section = str_replace( ']]', '', $section ); + $sectionTitle = clone( $title ); + $sectionTitle->mFragment = $section; + $link = $this->makeKnownLinkObj( $sectionTitle, wfMsg( 'sectionlink' ) ); } $sep='-'; $auto=$link.$auto; -- 2.20.1