From c975214f7f2de9309787748e7ee2b65e6c1142fc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Thu, 5 Aug 2010 16:22:42 +0000 Subject: [PATCH] Refactor so that tooltipAndAccesskeyAttribs does not cause 6 message cause hits if tooltip and accesskey don't even exists --- includes/Linker.php | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index a8d9c8b828..35da05d840 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1628,13 +1628,16 @@ class Linker { public function titleAttrib( $name, $options = null ) { wfProfileIn( __METHOD__ ); - $tooltip = wfMsg( "tooltip-$name" ); - # Compatibility: formerly some tooltips had [alt-.] hardcoded - $tooltip = preg_replace( "/ ?\[alt-.\]$/", '', $tooltip ); - - # Message equal to '-' means suppress it. - if ( wfEmptyMsg( "tooltip-$name", $tooltip ) || $tooltip == '-' ) { + if ( wfEmptyMsg( "tooltip-$name" ) ) { $tooltip = false; + } else { + $tooltip = wfMsg( "tooltip-$name" ); + # Compatibility: formerly some tooltips had [alt-.] hardcoded + $tooltip = preg_replace( "/ ?\[alt-.\]$/", '', $tooltip ); + # Message equal to '-' means suppress it. + if ( $tooltip == '-' ) { + $tooltip = false; + } } if ( $options == 'withaccess' ) { @@ -1665,18 +1668,20 @@ class Linker { public function accesskey( $name ) { wfProfileIn( __METHOD__ ); - $accesskey = wfMsg( "accesskey-$name" ); - - # FIXME: Per standard MW behavior, a value of '-' means to suppress the - # attribute, but this is broken for accesskey: that might be a useful - # value. - if( $accesskey != '' && $accesskey != '-' && !wfEmptyMsg( "accesskey-$name", $accesskey ) ) { - wfProfileOut( __METHOD__ ); - return $accesskey; + if ( wfEmptyMsg( "accesskey-$name" ) ) { + $accesskey = false; + } else { + $accesskey = wfMsg( "accesskey-$name" ); + if ( $accesskey === '' || $accesskey === '-' ) { + # FIXME: Per standard MW behavior, a value of '-' means to suppress the + # attribute, but this is broken for accesskey: that might be a useful + # value. + $accesskey = false; + } } wfProfileOut( __METHOD__ ); - return false; + return $accesskey; } /** @@ -2038,7 +2043,7 @@ class Linker { } /** - * Returns the attributes for the tooltip and access key + * Returns the attributes for the tooltip and access key. */ public function tooltipAndAccesskeyAttribs( $name ) { global $wgEnableTooltipsAndAccesskeys; -- 2.20.1