Fix for r71961 (moved SpecialPage constructor from named to __construct()). Intercept...
authorChad Horohoe <demon@users.mediawiki.org>
Fri, 10 Dec 2010 15:15:16 +0000 (15:15 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Fri, 10 Dec 2010 15:15:16 +0000 (15:15 +0000)
includes/SpecialPage.php
includes/specials/SpecialActiveusers.php

index 03e93e6..479cfd0 100644 (file)
@@ -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
          *
index f016ab9..bf3fd43 100644 (file)
@@ -165,7 +165,7 @@ class SpecialActiveUsers extends SpecialPage {
         * Constructor
         */
        public function __construct() {
-               parent::__construct( 'Activeusers' );
+               SpecialPage::SpecialPage( 'Activeusers' );
        }
 
        /**