(bug 15351) Fix fatal error for invalid section fragments in autocomments
authorAryeh Gregor <simetrical@users.mediawiki.org>
Thu, 28 Aug 2008 23:12:57 +0000 (23:12 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Thu, 28 Aug 2008 23:12:57 +0000 (23:12 +0000)
. . . 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
includes/Linker.php

index 113c8c4..d12e7df 100644 (file)
@@ -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 ===
index e076801..3f8f802 100644 (file)
@@ -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;