r86053 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86052‎ | r86053 | r86054 >
Date:15:11, 14 April 2011
Author:happy-melon
Status:ok
Tags:
Comment:
Changes to SpecialPage: deprecate any syntax for defining pages other than $wgSpecialPage['PageName'] = 'ClassName', including SpecialRedirectToSpecial, which is ugly and nasty anyway.
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php (modified) (history)
  • /trunk/extensions/OpenID/OpenID.hooks.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPage.php
@@ -80,13 +80,7 @@
8181 protected $mContext;
8282
8383 /**
84 - * List of special pages, followed by parameters.
85 - * If the only parameter is a string, that is the page name.
86 - * Otherwise, it is an array. The format is one of:
87 - ** array( 'SpecialPage', name, right )
88 - ** array( 'IncludableSpecialPage', name, right, listed? )
89 - ** array( 'UnlistedSpecialPage', name, right )
90 - ** array( 'SpecialRedirectToSpecial', name, page to redirect to, special page param, ... )
 84+ * List of special page names to the subclass of SpecialPage which handles them.
9185 */
9286 static public $mList = array(
9387 # Maintenance Reports
@@ -123,7 +117,7 @@
124118
125119 # Login/create account
126120 'Userlogin' => 'LoginForm',
127 - 'CreateAccount' => array( 'SpecialRedirectToSpecial', 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) ),
 121+ 'CreateAccount' => 'SpecialCreateAccount',
128122
129123 # Users and rights
130124 'Block' => 'SpecialBlock',
@@ -135,8 +129,8 @@
136130 'Contributions' => 'SpecialContributions',
137131 'Listgrouprights' => 'SpecialListGroupRights',
138132 'Listusers' => 'SpecialListUsers' ,
139 - 'Listadmins' => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
140 - 'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
 133+ 'Listadmins' => 'SpecialListAdmins',
 134+ 'Listbots' => 'SpecialListBots',
141135 'Activeusers' => 'SpecialActiveUsers',
142136 'Userrights' => 'UserrightsPage',
143137 'DisableAccount' => 'SpecialDisableAccount',
@@ -414,6 +408,8 @@
415409 $className = $rec;
416410 self::$mList[$name] = new $className;
417411 } elseif ( is_array( $rec ) ) {
 412+ // @deprecated officially since 1.18, unofficially since forever
 413+ wfDebug( "Array syntax for \$wgSpecialPages is deprecated, define a subclass of SpecialPage instead." );
418414 $className = array_shift( $rec );
419415 self::$mList[$name] = MWFunction::newObj( $className, $rec );
420416 }
@@ -752,13 +748,14 @@
753749 *
754750 * @param $fName String Name of called method
755751 * @param $a Array Arguments to the method
756 - * @deprecated Call isn't deprecated, but SpecialPage::SpecialPage() is
 752+ * @deprecated since 1.17, call parent::__construct()
757753 */
758754 public function __call( $fName, $a ) {
759755 // Sometimes $fName is SpecialPage, sometimes it's specialpage. <3 PHP
760756 if( strtolower( $fName ) == 'specialpage' ) {
761 - // Debug messages now, warnings in 1.19 or 1.20?
762 - wfDebug( "Deprecated SpecialPage::SpecialPage() called, use __construct();\n" );
 757+ // Deprecated messages now, remove in 1.19 or 1.20?
 758+ wfDeprecated( __METHOD__ );
 759+
763760 $name = isset( $a[0] ) ? $a[0] : '';
764761 $restriction = isset( $a[1] ) ? $a[1] : '';
765762 $listed = isset( $a[2] ) ? $a[2] : true;
@@ -1082,7 +1079,7 @@
10831080 * Shortcut to construct a special page alias.
10841081 * @ingroup SpecialPage
10851082 */
1086 -class SpecialRedirectToSpecial extends UnlistedSpecialPage {
 1083+abstract class SpecialRedirectToSpecial extends UnlistedSpecialPage {
10871084 var $redirName, $redirSubpage;
10881085
10891086 function __construct( $name, $redirName, $redirSubpage = false, $allowedRedirectParams = array(), $addedRedirectParams = array() ) {
@@ -1103,6 +1100,33 @@
11041101 }
11051102
11061103 /**
 1104+ * ListAdmins --> ListUsers/admin
 1105+ */
 1106+class SpecialListAdmins extends SpecialRedirectToSpecial {
 1107+ function __construct(){
 1108+ parent::__construct( 'ListAdmins', 'ListUsers', 'sysop' );
 1109+ }
 1110+}
 1111+
 1112+/**
 1113+ * ListBots --> ListUsers/admin
 1114+ */
 1115+class SpecialListBots extends SpecialRedirectToSpecial {
 1116+ function __construct(){
 1117+ parent::__construct( 'ListAdmins', 'ListUsers', 'bot' );
 1118+ }
 1119+}
 1120+
 1121+/**
 1122+ * CreateAccount --> UserLogin/signup
 1123+ * FIXME: this (and the rest of the login frontend) needs to die a horrible painful death
 1124+ */
 1125+class SpecialCreateAccount extends SpecialRedirectToSpecial {
 1126+ function __construct(){
 1127+ parent::__construct( 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) );
 1128+ }
 1129+}
 1130+/**
11071131 * SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
11081132 * are used to get user independant links pointing to the user page, talk
11091133 * page and list of contributions.
Index: trunk/extensions/OpenID/OpenID.hooks.php
@@ -1,13 +1,28 @@
22 <?php
33
 4+/**
 5+ * Redirect classes to hijack the core UserLogin and CreateAccount facilities, because
 6+ * they're so badly written as to be impossible to extend
 7+ */
 8+class SpecialOpenIDCreateAccount extends SpecialRedirectToSpecial {
 9+ function __construct(){
 10+ parent::__construct( 'SpecialOpenIDCreateAccount', 'OpenIDLogin' );
 11+ }
 12+}
 13+class SpecialOpenIDUserLogin extends SpecialRedirectToSpecial {
 14+ function __construct(){
 15+ parent::__construct( 'SpecialOpenIDUserLogin', 'OpenIDLogin', false, array( 'returnto', 'returntoquery' ) );
 16+ }
 17+}
 18+
419 class OpenIDHooks {
520 public static function onSpecialPage_initList( &$list ) {
621 global $wgOpenIDOnly, $wgOpenIDClientOnly;
722
823 if ( $wgOpenIDOnly ) {
9 - $list['Userlogin'] = array( 'SpecialRedirectToSpecial', 'Userlogin', 'OpenIDLogin', false, array( 'returnto', 'returntoquery' ) );
 24+ $list['Userlogin'] = 'SpecialOpenIDUserLogin';
1025 # Used in 1.12.x and above
11 - $list['CreateAccount'] = array( 'SpecialRedirectToSpecial', 'CreateAccount', 'OpenIDLogin' );
 26+ $list['CreateAccount'] = 'SpecialOpenIDCreateAccount';
1227 }
1328
1429 # Special pages are added at global scope; remove server-related ones
Index: trunk/extensions/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php
@@ -37,7 +37,7 @@
3838 )
3939 )
4040 );
41 - SpecialPage :: SpecialPage( 'Search' );
 41+ parent::__construct( 'Search' );
4242 }
4343 }
4444 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r100947Followup to r86053 - fix special page cases...nikerabbit05:57, 27 October 2011

Status & tagging log