From: Chad Horohoe Date: Fri, 10 Dec 2010 15:15:16 +0000 (+0000) Subject: Fix for r71961 (moved SpecialPage constructor from named to __construct()). Intercept... X-Git-Tag: 1.31.0-rc.0~33391 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=62d9f172badc3f8ac67b5d7e19e54a4edb9606ba;p=lhc%2Fweb%2Fwiklou.git Fix for r71961 (moved SpecialPage constructor from named to __construct()). Intercept calls to parent::SpecialPage() with __call() so we don't break people still using the old constructor. --- diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 03e93e68aa..479cfd0b1f 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -702,7 +702,16 @@ class SpecialPage { * @param $file String: file which is included by execute(). It is also constructed from $name by default * @param $includable Boolean: whether the page can be included in normal pages */ - function __construct( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) { + public function __construct( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) { + $this->init( $name, $restriction, $listed, $function, $file, $includable ); + } + + /** + * Do the real work for the constructor, mainly so __call() can intercept + * calls to SpecialPage() + * @see __construct() for param docs + */ + private function init( $name, $restriction, $listed, $function, $file, $includable ) { $this->mName = $name; $this->mRestriction = $restriction; $this->mListed = $listed; @@ -719,6 +728,29 @@ class SpecialPage { } } + /** + * Use PHP's magic __call handler to get calls to the old PHP4 constructor + * because PHP E_STRICT yells at you for having __construct() and SpecialPage() + * + * @param $name String Name of called method + * @param $a Array Arguments to the method + * @deprecated Call isn't deprecated, but SpecialPage::SpecialPage() is + */ + public function __call( $fName, $a ) { + // Sometimes $fName is SpecialPage, sometimes it's specialpage. <3 PHP + if( strtolower( $fName ) == 'specialpage' ) { + // Debug messages now, warnings in 1.19 or 1.20? + wfDebug( "Deprecated SpecialPage::SpecialPage() called, use __construct();\n" ); + $name = isset( $a[0] ) ? $a[0] : ''; + $restriction = isset( $a[1] ) ? $a[1] : ''; + $listed = isset( $a[2] ) ? $a[2] : true; + $function = isset( $a[3] ) ? $a[3] : false; + $file = isset( $a[4] ) ? $a[4] : 'default'; + $includable = isset( $a[5] ) ? $a[5] : false; + $this->init( $name, $restriction, $listed, $function, $file, $includable ); + } + } + /**#@+ * Accessor * diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index f016ab9292..bf3fd43df0 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -165,7 +165,7 @@ class SpecialActiveUsers extends SpecialPage { * Constructor */ public function __construct() { - parent::__construct( 'Activeusers' ); + SpecialPage::SpecialPage( 'Activeusers' ); } /**