From 5c1176af6a5e3e2d9ed4df686cfdc0ace0cf9d25 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Thu, 28 Aug 2008 23:12:57 +0000 Subject: [PATCH] (bug 15351) Fix fatal error for invalid section fragments in autocomments . . . probably. Actually I can't reproduce the problem, so I can't be sure if this fixes it. But it should. I'm not at all sure if this is a real fix or more of a workaround. One code path (!$local) normalizes the fragment and rejects it as invalid, while the other code path ($local) sets the fragment unquestioningly and doesn't validate it. I don't know which behavior is correct. --- RELEASE-NOTES | 1 + includes/Linker.php | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 113c8c4970..d12e7dff85 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -157,6 +157,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN namespace in Special:Watchlist * (bug 15172) 'Go' button of Special:Recentchanges now on the same line as the last input element (like Special:Watchlist too) +* (bug 15351) Fix fatal error for invalid section fragments in autocomments === API changes in 1.14 === diff --git a/includes/Linker.php b/includes/Linker.php index e076801881..3f8f802fda 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1222,11 +1222,18 @@ class Linker { $sectionTitle = clone( $title ); $sectionTitle->mFragment = $section; } - $link = $this->link( $sectionTitle, - wfMsgForContent( 'sectionlink' ), array(), array(), - 'noclasses' ); + # FIXME: $sectionTitle should probably always be valid at this + # point, but in some scenarios it's not (bug 15351). Is this cor- + # rect? + if( $title instanceof Title ) { + $link = $this->link( $sectionTitle, + wfMsgForContent( 'sectionlink' ), array(), array(), + 'noclasses' ); + } else { + $link = ''; + } } - $auto = $link . $auto; + $auto = "$link$auto"; if( $pre ) { # written summary $presep autocomment (summary /* section */) $auto = wfMsgExt( 'autocomment-prefix', array( 'escapenoentities', 'content' ) ) . $auto; -- 2.20.1