Revert r38149 for now, causes regressions in API parsing.
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 28 Jul 2008 23:00:14 +0000 (23:00 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 28 Jul 2008 23:00:14 +0000 (23:00 +0000)
Bug 14965 - https://bugzilla.wikimedia.org/show_bug.cgi?id=14965

PHP Catchable fatal error:  Argument 1 passed to Title::equals() must be an instance of Title, null given, called in /usr/local/apache/common-local/php-1.5/includes/Linker.php on line 1323 and defined in /usr/local/apache/common-local/php-1.5/includes/Title.php on line 3003
$wgTitle isn't available in this sort of background rendering.

RELEASE-NOTES
docs/hooks.txt
includes/Linker.php
includes/parser/Parser.php

index bbc2e39..2975b06 100644 (file)
@@ -29,8 +29,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 8068) New __INDEX__ and __NOINDEX__ magic words allow user control of
   search engine indexing on a per-article basis.
 * Handheld stylesheet options
-* Added 'DoEditSectionLink' hook as a cleaner unified version of the old
-  'EditSectionLink' and 'EditSectionLinkForOther' hooks
 
 === Bug fixes in 1.14 ===
 
index 3177ebf..2ef8cc9 100644 (file)
@@ -533,17 +533,6 @@ $newRev: Revision object of the "new" revision
 $article: article (object) being viewed
 $oldid: oldid (int) being viewed
 
-'DoEditSectionLink': Override the HTML generated for section edit links
-$skin: Skin object rendering the UI
-$title: Title object for the title being linked to (may not be the same as
-  $wgTitle, if the section is included from a template)
-$section: The designation of the section being pointed to, to be included in
-  the link, like "&section=$section"
-$tooltip: The default tooltip.  Escape with htmlspecialchars() before using.
-  By default, this is wrapped in the 'editsectionhint' message.
-$result: The HTML to return, prefilled with the default plus whatever other
-  changes earlier hooks have made
-
 'EditFilter': Perform checks on an edit
 $editor: Edit form (see includes/EditPage.php)
 $text: Contents of the edit box
@@ -590,14 +579,14 @@ sections.
 &$editpage: The current EditPage object
 &$buttons: Array of edit buttons "Save", "Preview", "Live", and "Diff"
 
-'EditSectionLink': Do not use, use DoEditSectionLink instead.
+'EditSectionLink': Override the return value of Linker::editSectionLink()
 $skin: Skin rendering the UI
 $title: Title being linked to
 $section: Section to link to
 $link: Default link
 $result: Result (alter this to override the generated links)
 
-'EditSectionLinkForOther': Do not use, use DoEditSectionLink instead.
+'EditSectionLinkForOther': Override the return value of Linker::editSectionLinkForOther()
 $skin: Skin rendering the UI
 $title: Title being linked to
 $section: Section to link to
index 2656b0d..03e7a9e 100644 (file)
@@ -1276,7 +1276,6 @@ class Linker {
         * @param $section Integer: section number.
         */
        public function editSectionLinkForOther( $title, $section ) {
-               wfDeprecated( __METHOD__ );
                $title = Title::newFromText( $title );
                return $this->doEditSectionLink( $title, $section, '', 'EditSectionLinkForOther' );
        }
@@ -1287,61 +1286,48 @@ class Linker {
         * @param $hint Link String: title, or default if omitted or empty
         */
        public function editSectionLink( Title $nt, $section, $hint='' ) {
-               wfDeprecated( __METHOD__ );
+               if( $hint != '' ) {
+                       $hint = wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) );
+                       $hint = " title=\"$hint\"";
+               }
                return $this->doEditSectionLink( $nt, $section, $hint, 'EditSectionLink' );
        }
 
        /**
-        * Create a section edit link.  This supersedes editSectionLink() and
-        * editSectionLinkForOther().
+        * Implement editSectionLink and editSectionLinkForOther.
         *
-        * @param $nt      Title  The title being linked to (may not be the same as
-        *   $wgTitle, if the section is included from a template)
-        * @param $section string The designation of the section being pointed to,
-        *   to be included in the link, like "&section=$section"
-        * @param $tooltip string The tooltip to use for the link: will be escaped
-        *   and wrapped in the 'editsectionhint' message
-        * @return         string HTML to use for edit link
+        * @param $nt      Title object
+        * @param $section Integer, section number
+        * @param $hint    String, for HTML title attribute
+        * @param $hook    String, name of hook to run
+        * @return         String, HTML to use for edit link
         */
-       public function doEditSectionLink( Title $nt, $section, $tooltip='' ) {
-               global $wgTitle;
-               $attribs = '';
-               if( $tooltip ) {
-                       $attribs = wfMsgHtml( 'editsectionhint', htmlspecialchars( $tooltip ) );
-                       $attribs = " title=\"$attribs\"";
-               }
-
+       protected function doEditSectionLink( Title $nt, $section, $hint, $hook ) {
+               global $wgContLang;
+               $editurl = '&section='.$section;
                $url = $this->makeKnownLinkObj(
                        $nt,
                        htmlspecialchars(wfMsg('editsection')),
-                       "action=edit&section=$section",
-                       '', '', '',  $attribs
+                       'action=edit'.$editurl,
+                       '', '', '',  $hint
                );
-
-               # Run the old hooks
                $result = null;
-               if( $nt->equals( $wgTitle ) ) {
-                       wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $attribs, $url, &$result ) );
-               } else {
+
+               // The two hooks have slightly different interfaces . . .
+               if( $hook == 'EditSectionLink' ) {
+                       wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $hint, $url, &$result ) );
+               } elseif( $hook == 'EditSectionLinkForOther' ) {
                        wfRunHooks( 'EditSectionLinkForOther', array( &$this, $nt, $section, $url, &$result ) );
                }
 
-               if( !is_null( $result ) ) {
-                       # For reverse compatibility, add the brackets *after* the hook is
-                       # run, and even add them to hook-provided text.  These hooks have
-                       # inconsistent and redundant interfaces, which is why they should
-                       # no longer be used.  Use DoEditSectionLink instead.
+               // For reverse compatibility, add the brackets *after* the hook is run,
+               // and even add them to hook-provided text.
+               if( is_null( $result ) ) {
                        $result = wfMsgHtml( 'editsection-brackets', $url );
-                       return "<span class=\"editsection\">$result</span>";
+               } else {
+                       $result = wfMsgHtml( 'editsection-brackets', $result );
                }
-
-               # Add the brackets and the span, and *then* run the nice new hook, with
-               # consistent and non-redundant arguments.
-               $result = wfMsgHtml( 'editsection-brackets', $url );
-               $result = "<span class=\"editsection\">$result</span>";
-
-               wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result ) );
-               return $result;
+               return "<span class=\"editsection\">$result</span>";
        }
 
        /**
index c074717..7f00824 100644 (file)
@@ -3609,9 +3609,9 @@ class Parser
                                if( $isTemplate ) {
                                        # Put a T flag in the section identifier, to indicate to extractSections()
                                        # that sections inside <includeonly> should be counted.
-                                       $editlink = $sk->doEditSectionLink(Title::newFromText( $titleText ), "T-$sectionIndex");
+                                       $editlink = $sk->editSectionLinkForOther($titleText, "T-$sectionIndex");
                                } else {
-                                       $editlink = $sk->doEditSectionLink($this->mTitle, $sectionIndex, $headlineHint);
+                                       $editlink = $sk->editSectionLink($this->mTitle, $sectionIndex, $headlineHint);
                                }
                        } else {
                                $editlink = '';