r60017 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60016‎ | r60017 | r60018 >
Date:20:45, 13 December 2009
Author:simetrical
Status:deferred (Comments)
Tags:
Comment:
More convenient format for $wgExternalAuthType

Now is the whole class name, not a suffix. This allows you to do things
like $wgExternalAuthType::someStaticMethod() instead of having to fiddle
with temporary variables.

This will obviously break anything that has $wgExternalAuthType already
configured, so if that's anyone but me, make sure to fix your configs.
This is still experimental.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/ExternalUser.php (modified) (history)
  • /trunk/phase3/includes/extauth/Hardcoded.php (modified) (history)
  • /trunk/phase3/includes/extauth/MediaWiki.php (modified) (history)
  • /trunk/phase3/includes/extauth/vB.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ExternalUser.php
@@ -43,8 +43,7 @@
4444 if ( is_null( $wgExternalAuthType ) ) {
4545 return false;
4646 }
47 - $class = "ExternalUser_$wgExternalAuthType";
48 - $obj = new $class;
 47+ $obj = new $wgExternalAuthType;
4948 if ( !$obj->initFromName( $name ) ) {
5049 return false;
5150 }
@@ -60,8 +59,7 @@
6160 if ( is_null( $wgExternalAuthType ) ) {
6261 return false;
6362 }
64 - $class = "ExternalUser_$wgExternalAuthType";
65 - $obj = new $class;
 63+ $obj = new $wgExternalAuthType;
6664 if ( !$obj->initFromId( $id ) ) {
6765 return false;
6866 }
@@ -77,8 +75,7 @@
7876 if ( is_null( $wgExternalAuthType ) ) {
7977 return false;
8078 }
81 - $class = "ExternalUser_$wgExternalAuthType";
82 - $obj = new $class;
 79+ $obj = new $wgExternalAuthType;
8380 if ( !$obj->initFromCookie( $cookie ) ) {
8481 return false;
8582 }
Index: trunk/phase3/includes/DefaultSettings.php
@@ -4148,8 +4148,8 @@
41494149 * be specified.
41504150 *
41514151 * null indicates no external authentication is to be used. Otherwise,
4152 - * "ExternalUser_$wgExternalAuthType" must be the name of a non-abstract class
4153 - * that extends ExternalUser.
 4152+ * $wgExternalAuthType must be the name of a non-abstract class that extends
 4153+ * ExternalUser.
41544154 *
41554155 * Core authentication modules can be found in includes/extauth/.
41564156 */
Index: trunk/phase3/includes/extauth/Hardcoded.php
@@ -21,7 +21,7 @@
2222 * This class supports external authentication from a literal array dumped in
2323 * LocalSettings.php. It's mostly useful for testing. Example configuration:
2424 *
25 - * $wgExternalAuthType = 'Hardcoded';
 25+ * $wgExternalAuthType = 'ExternalUser_Hardcoded';
2626 * $wgExternalAuthConf = array(
2727 * 'Bob Smith' => array(
2828 * 'password' => 'literal string',
Index: trunk/phase3/includes/extauth/MediaWiki.php
@@ -21,7 +21,7 @@
2222 * This class supports authentication against an external MediaWiki database,
2323 * probably any version back to 1.5 or something. Example configuration:
2424 *
25 - * $wgExternalAuthType = 'MediaWiki';
 25+ * $wgExternalAuthType = 'ExternalUser_MediaWiki';
2626 * $wgExternalAuthConf = array(
2727 * 'DBtype' => 'mysql',
2828 * 'DBserver' => 'localhost',
Index: trunk/phase3/includes/extauth/vB.php
@@ -23,7 +23,7 @@
2424 * code, only reads from the database. Example lines to put in
2525 * LocalSettings.php:
2626 *
27 - * $wgExternalAuthType = 'vB';
 27+ * $wgExternalAuthType = 'ExternalUser_vB';
2828 * $wgExternalAuthConf = array(
2929 * 'server' => 'localhost',
3030 * 'username' => 'forum',

Comments

#Comment by Simetrical (talk | contribs)   20:52, 13 December 2009

Well, the precise example I gave in the commit message doesn't actually work, it seems. But it's a more convenient format anyway.

#Comment by Happy-melon (talk | contribs)   22:42, 13 December 2009

It works for PHP>5.3, IIRC. I've run into a similar issue in an extension I'm writing at the moment.

#Comment by Simetrical (talk | contribs)   22:57, 13 December 2009

I just used call_user_func(). (Then realized my code was pointless and threw it out.)

#Comment by Happy-melon (talk | contribs)   23:01, 13 December 2009

Me too. Then I decided I needed late static binding and so slapped a big "needs PHP3.5" warning on top, and put the nicer call in. Then I realised that the server it's going to run on has PHP5.2.8 like everyone else. Fun times.

-D

Status & tagging log