r79523 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79522‎ | r79523 | r79524 >
Date:20:19, 3 January 2011
Author:soxred93
Status:resolved (Comments)
Tags:
Comment:
Throw an exception if calling parent or self on MWFunction.
Modified paths:
  • /trunk/phase3/includes/MWFunction.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/MWFunction.php
@@ -30,6 +30,14 @@
3131 }
3232 }
3333
 34+ $callback = (array) $callback;
 35+
 36+ if( count( $callback ) == 2 && $callback[0] == 'self' || $callback[0] == 'parent' ) {
 37+
 38+ throw new MWException( 'MWFunction cannot call self::method() or parent::method()' );
 39+
 40+ }
 41+
3442 // Run autoloader (workaround for call_user_func_array bug: http://bugs.php.net/bug.php?id=51329)
3543 is_callable( $callback );
3644

Follow-up revisions

RevisionCommit summaryAuthorDate
r79529Followup r79523: Test that calling self:: and parent:: throws exceptionsoxred9321:14, 3 January 2011
r79547Forcing array breaks MWFunction with <2 parameterssoxred9301:51, 4 January 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   21:46, 14 June 2011

+$callback = (array) $callback;

So "someGlobalFunc" now becomes array( "someGlobalFunc" ). Will that ever give "array must have exactly two members"?

#Comment by Aaron Schulz (talk | contribs)   21:49, 14 June 2011

By "that" I mean call_user_func().

#Comment by Aaron Schulz (talk | contribs)   22:30, 14 June 2011

Ahh, r79547.

Status & tagging log