r98598 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98597‎ | r98598 | r98599 >
Date:02:03, 1 October 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
* (bug 31289) Fix fatal error on special pages using $this->msg() on PHP 5.2

According to online PHP docs, func_get_args() doesn't work in function parameter lists until PHP 5.3.0.
It does, however, work as the *first* parameter, which happens here and there in older code (eg array_slice(func_get_args(),1)).
Assigning to a variable and passing through works fine for this case on PHP 5.2.17.
Modified paths:
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPage.php
@@ -681,7 +681,12 @@
682682 * @see wfMessage
683683 */
684684 public function msg( /* $args */ ) {
685 - return call_user_func_array( array( $this->getContext(), 'msg' ), func_get_args() );
 685+ // Note: can't use func_get_args() directly as second or later item in
 686+ // a parameter list until PHP 5.3 or you get a fatal error.
 687+ // Works fine as the first parameter, which appears elsewhere in the
 688+ // code base. Sighhhh.
 689+ $args = func_get_args();
 690+ return call_user_func_array( array( $this->getContext(), 'msg' ), $args );
686691 }
687692
688693 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r98599MFT r98598: PHP 5.2 compat fix in SpecialPage (bug 31289)brion02:04, 1 October 2011
r98752MFT r98578, r98598, r98656reedy12:51, 3 October 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   02:06, 1 October 2011

Looks like there's still PHP 5.2 machines in production (which there really should not be ;) -- needs a 1.18wmf1 merge.

#Comment by Reedy (talk | contribs)   17:34, 1 October 2011

They are finally going away.. slowly!

Status & tagging log