http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97794
Revision: 97794
Author: tstarling
Date: 2011-09-22 06:10:45 +0000 (Thu, 22 Sep 2011)
Log Message:
-----------
Fix for r76344: you can't access $wgUser during the CentralAuthAutoCreate hook,
because it's the same object that invoked CentralAuth via UserLoadFromSession,
after mLoadedItems is set to true but before any data is initialised. The
calling code in CentralAuth does permissions checks correctly, by creating a
new User object for the anonymous user who is logging in. That's what I've
implemented here too.
Most of the changes here are just propagating the anonymous user object through
the call stack.
Modified Paths:
--------------
trunk/extensions/TitleBlacklist/TitleBlacklist.hooks.php
trunk/extensions/TitleBlacklist/TitleBlacklist.list.php
Modified: trunk/extensions/TitleBlacklist/TitleBlacklist.hooks.php
===================================================================
--- trunk/extensions/TitleBlacklist/TitleBlacklist.hooks.php 2011-09-22
05:01:19 UTC (rev 97793)
+++ trunk/extensions/TitleBlacklist/TitleBlacklist.hooks.php 2011-09-22
06:10:45 UTC (rev 97794)
@@ -74,10 +74,10 @@
*
* @return bool Acceptable
*/
- private static function acceptNewUserName( $userName, &$err, $override
= true ) {
- global $wgUser;
+ private static function acceptNewUserName( $userName, $permissionsUser,
&$err, $override = true ) {
$title = Title::makeTitleSafe( NS_USER, $userName );
- $blacklisted = TitleBlacklist::singleton()->userCannot( $title,
$wgUser, 'new-account', $override );
+ $blacklisted = TitleBlacklist::singleton()->userCannot( $title,
$permissionsUser,
+ 'new-account', $override );
if( $blacklisted instanceof TitleBlacklistEntry ) {
$message = $blacklisted->getErrorMessage( 'new-account'
);
$err = wfMsgWikiHtml( $message, $blacklisted->getRaw(),
$userName );
@@ -94,13 +94,15 @@
public static function abortNewAccount( $user, &$message ) {
global $wgUser, $wgRequest;
$override = $wgRequest->getCheck( 'wpIgnoreTitleBlacklist' );
- return self::acceptNewUserName( $user->getName(), $message,
$override );
+ return self::acceptNewUserName( $user->getName(), $wgUser,
$message, $override );
}
/** CentralAuthAutoCreate hook */
public static function centralAuthAutoCreate( $user, $userName ) {
$message = ''; # Will be ignored
- return self::acceptNewUserName( $userName, $message );
+ $anon = new User;
+ global $wgUser;
+ return self::acceptNewUserName( $userName, $anon, $message );
}
/**
@@ -169,9 +171,9 @@
/** UserCreateForm hook based on the one from AntiSpoof extension */
public static function addOverrideCheckbox( &$template ) {
- global $wgRequest;
+ global $wgRequest, $wgUser;
- if ( TitleBlacklist::userCanOverride( 'new-account' ) ) {
+ if ( TitleBlacklist::userCanOverride( $wgUser, 'new-account' )
) {
$template->addInputItem( 'wpIgnoreTitleBlacklist',
$wgRequest->getCheck( 'wpIgnoreTitleBlacklist'
),
'checkbox', 'titleblacklist-override' );
Modified: trunk/extensions/TitleBlacklist/TitleBlacklist.list.php
===================================================================
--- trunk/extensions/TitleBlacklist/TitleBlacklist.list.php 2011-09-22
05:01:19 UTC (rev 97793)
+++ trunk/extensions/TitleBlacklist/TitleBlacklist.list.php 2011-09-22
06:10:45 UTC (rev 97794)
@@ -152,7 +152,7 @@
* otherwise FALSE
*/
public function userCannot( $title, $user, $action = 'edit', $override
= true ) {
- if( $override && self::userCanOverride( $action ) ) {
+ if( $override && self::userCanOverride( $user, $action ) ) {
return false;
} else {
return $this->isBlacklisted( $title, $action );
@@ -283,10 +283,9 @@
*
* @return bool
*/
- public static function userCanOverride( $action ) {
- global $wgUser;
- return $wgUser->isAllowed( 'tboverride' ) ||
- ( $action == 'new-account' && $wgUser->isAllowed(
'tboverride-account' ) );
+ public static function userCanOverride( $user, $action ) {
+ return $user->isAllowed( 'tboverride' ) ||
+ ( $action == 'new-account' && $user->isAllowed(
'tboverride-account' ) );
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs