r70506 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70505‎ | r70506 | r70507 >
Date:16:22, 5 August 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Refactor so that tooltipAndAccesskeyAttribs does not cause 6 message cause hits if tooltip and accesskey don't even exists
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -1628,13 +1628,16 @@
16291629 public function titleAttrib( $name, $options = null ) {
16301630 wfProfileIn( __METHOD__ );
16311631
1632 - $tooltip = wfMsg( "tooltip-$name" );
1633 - # Compatibility: formerly some tooltips had [alt-.] hardcoded
1634 - $tooltip = preg_replace( "/ ?\[alt-.\]$/", '', $tooltip );
1635 -
1636 - # Message equal to '-' means suppress it.
1637 - if ( wfEmptyMsg( "tooltip-$name", $tooltip ) || $tooltip == '-' ) {
 1632+ if ( wfEmptyMsg( "tooltip-$name" ) ) {
16381633 $tooltip = false;
 1634+ } else {
 1635+ $tooltip = wfMsg( "tooltip-$name" );
 1636+ # Compatibility: formerly some tooltips had [alt-.] hardcoded
 1637+ $tooltip = preg_replace( "/ ?\[alt-.\]$/", '', $tooltip );
 1638+ # Message equal to '-' means suppress it.
 1639+ if ( $tooltip == '-' ) {
 1640+ $tooltip = false;
 1641+ }
16391642 }
16401643
16411644 if ( $options == 'withaccess' ) {
@@ -1665,18 +1668,20 @@
16661669 public function accesskey( $name ) {
16671670 wfProfileIn( __METHOD__ );
16681671
1669 - $accesskey = wfMsg( "accesskey-$name" );
1670 -
1671 - # FIXME: Per standard MW behavior, a value of '-' means to suppress the
1672 - # attribute, but this is broken for accesskey: that might be a useful
1673 - # value.
1674 - if( $accesskey != '' && $accesskey != '-' && !wfEmptyMsg( "accesskey-$name", $accesskey ) ) {
1675 - wfProfileOut( __METHOD__ );
1676 - return $accesskey;
 1672+ if ( wfEmptyMsg( "accesskey-$name" ) ) {
 1673+ $accesskey = false;
 1674+ } else {
 1675+ $accesskey = wfMsg( "accesskey-$name" );
 1676+ if ( $accesskey === '' || $accesskey === '-' ) {
 1677+ # FIXME: Per standard MW behavior, a value of '-' means to suppress the
 1678+ # attribute, but this is broken for accesskey: that might be a useful
 1679+ # value.
 1680+ $accesskey = false;
 1681+ }
16771682 }
16781683
16791684 wfProfileOut( __METHOD__ );
1680 - return false;
 1685+ return $accesskey;
16811686 }
16821687
16831688 /**
@@ -2038,7 +2043,7 @@
20392044 }
20402045
20412046 /**
2042 - * Returns the attributes for the tooltip and access key
 2047+ * Returns the attributes for the tooltip and access key.
20432048 */
20442049 public function tooltipAndAccesskeyAttribs( $name ) {
20452050 global $wgEnableTooltipsAndAccesskeys;

Status & tagging log