r70940 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70939‎ | r70940 | r70941 >
Date:12:30, 12 August 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Followup r70783. Give doEditSectionLink an extra parameter with the language to use for the editsection.
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -3967,9 +3967,9 @@
39683968 if ( $isTemplate ) {
39693969 # Put a T flag in the section identifier, to indicate to extractSections()
39703970 # that sections inside <includeonly> should be counted.
3971 - $editlink = $sk->doEditSectionLink( Title::newFromText( $titleText ), "T-$sectionIndex" );
 3971+ $editlink = $sk->doEditSectionLink( Title::newFromText( $titleText ), "T-$sectionIndex", null, $this->mOptions->getUserLang() );
39723972 } else {
3973 - $editlink = $sk->doEditSectionLink( $this->mTitle, $sectionIndex, $headlineHint );
 3973+ $editlink = $sk->doEditSectionLink( $this->mTitle, $sectionIndex, $headlineHint, $this->mOptions->getUserLang() );
39743974 }
39753975 } else {
39763976 $editlink = '';
Index: trunk/phase3/includes/Linker.php
@@ -1375,16 +1375,17 @@
13761376 * to be included in the link, like "&section=$section"
13771377 * @param $tooltip string The tooltip to use for the link: will be escaped
13781378 * and wrapped in the 'editsectionhint' message
 1379+ * @param $lang string Language code
13791380 * @return string HTML to use for edit link
13801381 */
1381 - public function doEditSectionLink( Title $nt, $section, $tooltip = null ) {
 1382+ public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {
13821383 // HTML generated here should probably have userlangattributes
13831384 // added to it for LTR text on RTL pages
13841385 $attribs = array();
13851386 if( !is_null( $tooltip ) ) {
1386 - $attribs['title'] = wfMsg( 'editsectionhint', $tooltip );
 1387+ $attribs['title'] = wfMsgReal( 'editsectionhint', array( $tooltip ), true, $lang );
13871388 }
1388 - $link = $this->link( $nt, wfMsg('editsection'),
 1389+ $link = $this->link( $nt, wfMsgExt( 'editsection', array( 'language'=> $lang ) ),
13891390 $attribs,
13901391 array( 'action' => 'edit', 'section' => $section ),
13911392 array( 'noclasses', 'known' )
@@ -1394,7 +1395,7 @@
13951396 # we can rid of it someday.
13961397 $attribs = '';
13971398 if( $tooltip ) {
1398 - $attribs = wfMsgHtml( 'editsectionhint', htmlspecialchars( $tooltip ) );
 1399+ $attribs = htmlspecialchars( wfMsgReal( 'editsectionhint', array( $tooltip ), true, $lang ) );
13991400 $attribs = " title=\"$attribs\"";
14001401 }
14011402 $result = null;
@@ -1404,13 +1405,13 @@
14051406 # run, and even add them to hook-provided text. (This is the main
14061407 # reason that the EditSectionLink hook is deprecated in favor of
14071408 # DoEditSectionLink: it can't change the brackets or the span.)
1408 - $result = wfMsgHtml( 'editsection-brackets', $result );
 1409+ $result = wfMsgExt( 'editsection-brackets', array( 'escape', 'replaceafter', 'language'=>$lang ), $link );
14091410 return "<span class=\"editsection\">$result</span>";
14101411 }
14111412
14121413 # Add the brackets and the span, and *then* run the nice new hook, with
14131414 # clean and non-redundant arguments.
1414 - $result = wfMsgHtml( 'editsection-brackets', $link );
 1415+ $result = wfMsgExt( 'editsection-brackets', array( 'escape', 'replaceafter', 'language'=>$lang ), $link );
14151416 $result = "<span class=\"editsection\">$result</span>";
14161417
14171418 wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result ) );

Follow-up revisions

RevisionCommit summaryAuthorDate
r74697Follow up r70940. This call should use the hook $result.platonides23:20, 12 October 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70783Use only the page relevant pieces in the parser cache key. Eg. two users with...platonides21:53, 9 August 2010

Comments

#Comment by Jpond (talk | contribs)   21:33, 12 October 2010

This code breaks EditSectionLink hook because it only allows a single link to be put on the section line. Example:

 $result = wfMsgHtml( 'editsection-brackets', $result );
  return "$result";

Specifically, this causes a problem with Extension:DiscussionThreading, because it changes the net result from:

<a href="https://www.mediawiki.org/CurrentVersion/index.php?title=Talk:Main_Page&action=edit&section=new" title="Start a new thread">new</a>][<a href="https://www.mediawiki.org/CurrentVersion/index.php?title=Talk:Main_Page&action=edit&section=1" title="Edit section: Testing -- WikiSysop 08:22, 7 October 2009 (EDT)">edit</a>][<a href="https://www.mediawiki.org/CurrentVersion/index.php?title=Talk:Main_Page&action=edit&section=1&replyto=yes" title="Reply to this posting">reply</a>

or in browser version, new][edit][reply

to:

[<a href="https://www.mediawiki.org/CurrentVersion/index.php?title=Talk:Main_Page&action=edit&section=1" title="Edit section: Testing -- WikiSysop 08:22, 7 October 2009 (EDT)">edit</a>]E

or in browser: [edit]

which destroys the whole purpose of the hook.


Note: This would also do the same if hook 'DoEditSectionLink' instead of 'EditSectionLink'

#Comment by Platonides (talk | contribs)   23:22, 12 October 2010

I had used $link instead of $result. Fixed in r74697. Can you test if that fixes it?

The report is a bit confuse. I am not changing the parameters.

Status & tagging log