http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97798

Revision: 97798
Author:   tstarling
Date:     2011-09-22 06:32:32 +0000 (Thu, 22 Sep 2011)
Log Message:
-----------
MFT r97794, r97797: Fixed TitleBlacklist which was causing "Invalid argument 
supplied for foreach()" when automatic account creation was attempted on a 1.18 
wiki.

Modified Paths:
--------------
    branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.hooks.php
    branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.list.php

Property Changed:
----------------
    branches/wmf/1.18wmf1/extensions/TitleBlacklist/


Property changes on: branches/wmf/1.18wmf1/extensions/TitleBlacklist
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/REL1_15/phase3/extensions/TitleBlacklist:51646
/branches/new-installer/phase3/extensions/TitleBlacklist:43664-66004
/branches/sqlite/extensions/TitleBlacklist:58211-58321
/branches/wmf/1.16wmf4/extensions/TitleBlacklist:67177,69199,76243,77266
/branches/wmf-deployment/extensions/TitleBlacklist:60970
/trunk/phase3/extensions/TitleBlacklist:79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,80406,81833,83212,83590
   + /branches/REL1_15/phase3/extensions/TitleBlacklist:51646
/branches/new-installer/phase3/extensions/TitleBlacklist:43664-66004
/branches/sqlite/extensions/TitleBlacklist:58211-58321
/branches/wmf/1.16wmf4/extensions/TitleBlacklist:67177,69199,76243,77266
/branches/wmf-deployment/extensions/TitleBlacklist:60970
/trunk/extensions/TitleBlacklist:97794,97797
/trunk/phase3/extensions/TitleBlacklist:79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,80406,81833,83212,83590

Modified: 
branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.hooks.php
===================================================================
--- branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.hooks.php    
2011-09-22 06:28:55 UTC (rev 97797)
+++ branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.hooks.php    
2011-09-22 06:32:32 UTC (rev 97798)
@@ -76,10 +76,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 );
@@ -96,13 +96,14 @@
        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;
+               return self::acceptNewUserName( $userName, $anon, $message );
        }
 
        /** EditFilter hook
@@ -169,9 +170,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: 
branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.list.php
===================================================================
--- branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.list.php     
2011-09-22 06:28:55 UTC (rev 97797)
+++ branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.list.php     
2011-09-22 06:32:32 UTC (rev 97798)
@@ -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 );
@@ -280,10 +280,9 @@
         * 
         * @param $action Action
         */
-       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

Reply via email to