From 6dc8e2b09f585a1dc64cf05cec87b3534cbc11ac Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 14 Jul 2006 16:08:16 +0000 Subject: [PATCH] Fixed Parser::setFunctionHook(), broken by last commit. Passed parserTests.php either way due to conincidence. Also fixed a couple of comments broken by perl script^W^W meticulous hand-editing. --- includes/Parser.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index e79f038cbe..2305da1821 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -3604,7 +3604,7 @@ class Parser } # Trim trailing whitespace - # 'end' (__END__) tag allows for trailing + # __END__ tag allows for trailing # whitespace to be deliberately included $text = rtrim( $text ); $mw =& MagicWord::get( 'end' ); @@ -3779,7 +3779,7 @@ class Parser * * @public * - * @param mixed $id The magic word ID, or (deprecated) the function name. Function names are case-insensitive. + * @param mixed $id The magic word ID * @param mixed $callback The callback function (and object) to use * @param integer $flags a combination of the following flags: * SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{#if:...}} @@ -3787,22 +3787,19 @@ class Parser * @return The old callback function for this name, if any */ function setFunctionHook( $id, $callback, $flags = 0 ) { - if( is_string( $id ) ) { - $id = strtolower( $id ); - } $oldVal = @$this->mFunctionHooks[$id]; $this->mFunctionHooks[$id] = $callback; # Add to function cache - if ( is_int( $id ) ) { - $mw = MagicWord::get( $id ); - $synonyms = $mw->getSynonyms(); - $sensitive = intval( $mw->isCaseSensitive() ); - } else { - $synonyms = array( $id ); - $sensitive = 0; + $mw = MagicWord::get( $id ); + if ( !$mw ) { + throw new MWException( 'The calling convention to Parser::setFunctionHook() has changed, ' . + 'it is now required to pass a MagicWord ID as the first parameter.' ); } + $synonyms = $mw->getSynonyms(); + $sensitive = intval( $mw->isCaseSensitive() ); + foreach ( $synonyms as $syn ) { # Case if ( !$sensitive ) { @@ -4145,7 +4142,7 @@ class Parser # remember to set an alignment, don't render immediately $align = 'none'; } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) { - wfDebug( "'img_width' match: $match\n" ); + wfDebug( "img_width match: $match\n" ); # $match is the image width in pixels if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) { $width = intval( $m[1] ); -- 2.20.1