r40305 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40304‎ | r40305 | r40306 >
Date:15:05, 1 September 2008
Author:tstarling
Status:old
Tags:
Comment:
Fix r40194, which was obviously incorrect. There's no reason $sectionTitle should be valid, so you should probably check to see if Title::newFromText() succeeded, rather than checking the validity of some unrelated variable. Also: use the new three-parameter Title::makeTitleSafe(), instead of cloning and setting mFragment directly.
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -1219,13 +1219,10 @@
12201220 if ( $local ) {
12211221 $sectionTitle = Title::newFromText( '#' . $section );
12221222 } else {
1223 - $sectionTitle = clone( $title );
1224 - $sectionTitle->mFragment = $section;
 1223+ $sectionTitle = Title::makeTitleSafe( $title->getNamespace(),
 1224+ $title->getDBkey(), $section );
12251225 }
1226 - # FIXME: $sectionTitle should probably always be valid at this
1227 - # point, but in some scenarios it's not (bug 15351). Is this cor-
1228 - # rect?
1229 - if( $title instanceof Title ) {
 1226+ if ( $sectionTitle ) {
12301227 $link = $this->link( $sectionTitle,
12311228 wfMsgForContent( 'sectionlink' ), array(), array(),
12321229 'noclasses' );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r40194(bug 15351) Fix fatal error for invalid section fragments in autocomments...simetrical23:12, 28 August 2008