r65117 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65116‎ | r65117 | r65118 >
Date:11:00, 16 April 2010
Author:brion
Status:ok
Tags:
Comment:
Clean up some old PHP 4-style references passing $parsers around in ParserFunctions. Caused PHP warning output when using some functions on PHP 5.3.
Modified paths:
  • /trunk/extensions/ParserFunctions/ParserFunctions.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php
@@ -6,7 +6,7 @@
77 var $mTimeChars = 0;
88 var $mMaxTimeChars = 6000; # ~10 seconds
99
10 - function clearState(&$parser) {
 10+ function clearState( $parser) {
1111 $this->mTimeChars = 0;
1212 $parser->pf_ifexist_breakdown = array();
1313 $parser->pf_markerRegex = null;
@@ -57,7 +57,7 @@
5858 return $this->mExprParser;
5959 }
6060
61 - function expr( &$parser, $expr = '' ) {
 61+ function expr( $parser, $expr = '' ) {
6262 try {
6363 return $this->getExprParser()->doExpression( $expr );
6464 } catch(ExprError $e) {
@@ -65,7 +65,7 @@
6666 }
6767 }
6868
69 - function ifexpr( &$parser, $expr = '', $then = '', $else = '' ) {
 69+ function ifexpr( $parser, $expr = '', $then = '', $else = '' ) {
7070 try{
7171 $ret = $this->getExprParser()->doExpression( $expr );
7272 if ( is_numeric( $ret ) ) {
@@ -92,7 +92,7 @@
9393 return $result;
9494 }
9595
96 - function ifHook( &$parser, $test = '', $then = '', $else = '' ) {
 96+ function ifHook( $parser, $test = '', $then = '', $else = '' ) {
9797 if ( $test !== '' ) {
9898 return $then;
9999 } else {
@@ -100,7 +100,7 @@
101101 }
102102 }
103103
104 - function ifObj( &$parser, $frame, $args ) {
 104+ function ifObj( $parser, $frame, $args ) {
105105 $test = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
106106 if ( $test !== '' ) {
107107 return isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : '';
@@ -109,7 +109,7 @@
110110 }
111111 }
112112
113 - function ifeq( &$parser, $left = '', $right = '', $then = '', $else = '' ) {
 113+ function ifeq( $parser, $left = '', $right = '', $then = '', $else = '' ) {
114114 if ( $left == $right ) {
115115 return $then;
116116 } else {
@@ -117,7 +117,7 @@
118118 }
119119 }
120120
121 - function ifeqObj( &$parser, $frame, $args ) {
 121+ function ifeqObj( $parser, $frame, $args ) {
122122 $left = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
123123 $right = isset( $args[1] ) ? trim( $frame->expand( $args[1] ) ) : '';
124124 if ( $left == $right ) {
@@ -127,7 +127,7 @@
128128 }
129129 }
130130
131 - function iferror( &$parser, $test = '', $then = '', $else = false ) {
 131+ function iferror( $parser, $test = '', $then = '', $else = false ) {
132132 if ( preg_match( '/<(?:strong|span|p|div)\s(?:[^\s>]*\s+)*?class="(?:[^"\s>]*\s+)*?error(?:\s[^">]*)?"/', $test ) ) {
133133 return $then;
134134 } elseif ( $else === false ) {
@@ -137,7 +137,7 @@
138138 }
139139 }
140140
141 - function iferrorObj( &$parser, $frame, $args ) {
 141+ function iferrorObj( $parser, $frame, $args ) {
142142 $test = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
143143 $then = isset( $args[1] ) ? $args[1] : false;
144144 $else = isset( $args[2] ) ? $args[2] : false;
@@ -149,7 +149,7 @@
150150 }
151151 }
152152
153 - function switchHook( &$parser /*,...*/ ) {
 153+ function switchHook( $parser /*,...*/ ) {
154154 $args = func_get_args();
155155 array_shift( $args );
156156 $primary = trim(array_shift($args));
@@ -248,7 +248,7 @@
249249 * Following subpage link syntax instead of standard path syntax, an
250250 * initial slash is treated as a relative path, and vice versa.
251251 */
252 - public function rel2abs( &$parser , $to = '' , $from = '' ) {
 252+ public function rel2abs( $parser , $to = '' , $from = '' ) {
253253
254254 $from = trim($from);
255255 if( $from == '' ) {
@@ -317,11 +317,11 @@
318318 return $parser->mExpensiveFunctionCount <= $wgExpensiveParserFunctionLimit;
319319 }
320320
321 - function ifexist( &$parser, $title = '', $then = '', $else = '' ) {
 321+ function ifexist( $parser, $title = '', $then = '', $else = '' ) {
322322 return $this->ifexistCommon( $parser, false, $title, $then, $else );
323323 }
324324
325 - function ifexistCommon( &$parser, $frame, $titletext = '', $then = '', $else = '' ) {
 325+ function ifexistCommon( $parser, $frame, $titletext = '', $then = '', $else = '' ) {
326326 global $wgContLang;
327327 $title = Title::newFromText( $titletext );
328328 $wgContLang->findVariantLink( $titletext, $title, true );
@@ -374,7 +374,7 @@
375375 return $else;
376376 }
377377
378 - function ifexistObj( &$parser, $frame, $args ) {
 378+ function ifexistObj( $parser, $frame, $args ) {
379379 $title = isset( $args[0] ) ? trim( $frame->expand( $args[0] ) ) : '';
380380 $then = isset( $args[1] ) ? $args[1] : null;
381381 $else = isset( $args[2] ) ? $args[2] : null;
@@ -387,7 +387,7 @@
388388 }
389389 }
390390
391 - function time( &$parser, $format = '', $date = '', $local = false ) {
 391+ function time( $parser, $format = '', $date = '', $local = false ) {
392392 global $wgContLang, $wgLocaltimezone;
393393 if ( isset( $this->mTimeCache[$format][$date][$local] ) ) {
394394 return $this->mTimeCache[$format][$date][$local];
@@ -484,7 +484,7 @@
485485 return $result;
486486 }
487487
488 - function localTime( &$parser, $format = '', $date = '' ) {
 488+ function localTime( $parser, $format = '', $date = '' ) {
489489 return $this->time( $parser, $format, $date, true );
490490 }
491491
@@ -544,7 +544,7 @@
545545 *
546546 * Reports number of characters in string.
547547 */
548 - function runLen ( &$parser, $inStr = '' ) {
 548+ function runLen ( $parser, $inStr = '' ) {
549549 wfProfileIn( __METHOD__ );
550550
551551 $inStr = $this->killMarkers( $parser, (string)$inStr );
@@ -562,7 +562,7 @@
563563 * Note: If the needle is an empty string, single space is used instead.
564564 * Note: If the needle is not found, empty string is returned.
565565 */
566 - function runPos ( &$parser, $inStr = '', $inNeedle = '', $inOffset = 0 ) {
 566+ function runPos ( $parser, $inStr = '', $inNeedle = '', $inOffset = 0 ) {
567567 wfProfileIn( __METHOD__ );
568568
569569 $inStr = $this->killMarkers( $parser, (string)$inStr );
@@ -591,7 +591,7 @@
592592 * Note: If the needle is an empty string, single space is used instead.
593593 * Note: If the needle is not found, -1 is returned.
594594 */
595 - function runRPos ( &$parser, $inStr = '', $inNeedle = '' ) {
 595+ function runRPos ( $parser, $inStr = '', $inNeedle = '' ) {
596596 wfProfileIn( __METHOD__ );
597597
598598 $inStr = $this->killMarkers( $parser, (string)$inStr );
@@ -624,7 +624,7 @@
625625 * Note: A negative value for "length" returns a string reduced in
626626 * length by that amount.
627627 */
628 - function runSub ( &$parser, $inStr = '', $inStart = 0, $inLength = 0 ) {
 628+ function runSub ( $parser, $inStr = '', $inStart = 0, $inLength = 0 ) {
629629 wfProfileIn( __METHOD__ );
630630
631631 $inStr = $this->killMarkers( $parser, (string)$inStr );
@@ -651,7 +651,7 @@
652652 *
653653 * Note: If "substr" is empty, a single space is used.
654654 */
655 - function runCount ( &$parser, $inStr = '', $inSubStr = '' ) {
 655+ function runCount ( $parser, $inStr = '', $inSubStr = '' ) {
656656 wfProfileIn( __METHOD__ );
657657
658658 $inStr = $this->killMarkers( $parser, (string)$inStr );
@@ -680,7 +680,7 @@
681681 * Note: Armored against replacements that would generate huge strings.
682682 * Note: If "from" is an empty string, single space is used instead.
683683 */
684 - function runReplace( &$parser, $inStr = '',
 684+ function runReplace( $parser, $inStr = '',
685685 $inReplaceFrom = '', $inReplaceTo = '', $inLimit = -1 ) {
686686 global $wgPFStringLengthLimit;
687687 wfProfileIn( __METHOD__ );
@@ -738,7 +738,7 @@
739739 * Note: If the divider is an empty string, single space is used instead.
740740 * Note: Empty string is returned if there are not enough exploded chunks.
741741 */
742 - function runExplode ( &$parser, $inStr = '', $inDiv = '', $inPos = 0 ) {
 742+ function runExplode ( $parser, $inStr = '', $inDiv = '', $inPos = 0 ) {
743743 wfProfileIn( __METHOD__ );
744744
745745 $inStr = $this->killMarkers( $parser, (string)$inStr );
Index: trunk/extensions/ParserFunctions/ParserFunctions.php
@@ -64,7 +64,7 @@
6565 class ParserFunctions_HookStub {
6666 var $realObj;
6767
68 - function registerParser( &$parser ) {
 68+ function registerParser( $parser ) {
6969 global $wgPFEnableStringFunctions;
7070
7171 if ( defined( get_class( $parser ) . '::SFH_OBJECT_ARGS' ) ) {
@@ -105,7 +105,7 @@
106106 }
107107
108108 /** Defer ParserClearState */
109 - function clearState( &$parser ) {
 109+ function clearState( $parser ) {
110110 if ( !is_null( $this->realObj ) ) {
111111 $this->realObj->clearState( $parser );
112112 }

Status & tagging log