r97798 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97797‎ | r97798 | r97799 >
Date:06:32, 22 September 2011
Author:tstarling
Status:ok
Tags:
Comment:
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 (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.hooks.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.list.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.hooks.php
@@ -76,10 +76,10 @@
7777 *
7878 * @return bool Acceptable
7979 */
80 - private static function acceptNewUserName( $userName, &$err, $override = true ) {
81 - global $wgUser;
 80+ private static function acceptNewUserName( $userName, $permissionsUser, &$err, $override = true ) {
8281 $title = Title::makeTitleSafe( NS_USER, $userName );
83 - $blacklisted = TitleBlacklist::singleton()->userCannot( $title, $wgUser, 'new-account', $override );
 82+ $blacklisted = TitleBlacklist::singleton()->userCannot( $title, $permissionsUser,
 83+ 'new-account', $override );
8484 if( $blacklisted instanceof TitleBlacklistEntry ) {
8585 $message = $blacklisted->getErrorMessage( 'new-account' );
8686 $err = wfMsgWikiHtml( $message, $blacklisted->getRaw(), $userName );
@@ -96,13 +96,14 @@
9797 public static function abortNewAccount( $user, &$message ) {
9898 global $wgUser, $wgRequest;
9999 $override = $wgRequest->getCheck( 'wpIgnoreTitleBlacklist' );
100 - return self::acceptNewUserName( $user->getName(), $message, $override );
 100+ return self::acceptNewUserName( $user->getName(), $wgUser, $message, $override );
101101 }
102102
103103 /** CentralAuthAutoCreate hook */
104104 public static function centralAuthAutoCreate( $user, $userName ) {
105105 $message = ''; # Will be ignored
106 - return self::acceptNewUserName( $userName, $message );
 106+ $anon = new User;
 107+ return self::acceptNewUserName( $userName, $anon, $message );
107108 }
108109
109110 /** EditFilter hook
@@ -169,9 +170,9 @@
170171
171172 /** UserCreateForm hook based on the one from AntiSpoof extension */
172173 public static function addOverrideCheckbox( &$template ) {
173 - global $wgRequest;
 174+ global $wgRequest, $wgUser;
174175
175 - if ( TitleBlacklist::userCanOverride( 'new-account' ) ) {
 176+ if ( TitleBlacklist::userCanOverride( $wgUser, 'new-account' ) ) {
176177 $template->addInputItem( 'wpIgnoreTitleBlacklist',
177178 $wgRequest->getCheck( 'wpIgnoreTitleBlacklist' ),
178179 'checkbox', 'titleblacklist-override' );
Index: branches/wmf/1.18wmf1/extensions/TitleBlacklist/TitleBlacklist.list.php
@@ -152,7 +152,7 @@
153153 * otherwise FALSE
154154 */
155155 public function userCannot( $title, $user, $action = 'edit', $override = true ) {
156 - if( $override && self::userCanOverride( $action ) )
 156+ if( $override && self::userCanOverride( $user, $action ) )
157157 return false;
158158 else
159159 return $this->isBlacklisted( $title, $action );
@@ -280,10 +280,9 @@
281281 *
282282 * @param $action Action
283283 */
284 - public static function userCanOverride( $action ) {
285 - global $wgUser;
286 - return $wgUser->isAllowed( 'tboverride' ) ||
287 - ( $action == 'new-account' && $wgUser->isAllowed( 'tboverride-account' ) );
 284+ public static function userCanOverride( $user, $action ) {
 285+ return $user->isAllowed( 'tboverride' ) ||
 286+ ( $action == 'new-account' && $user->isAllowed( 'tboverride-account' ) );
288287 }
289288 }
290289
Property changes on: branches/wmf/1.18wmf1/extensions/TitleBlacklist
___________________________________________________________________
Modified: svn:mergeinfo
291290 Merged /trunk/extensions/TitleBlacklist:r97794,97797

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97794Fix for r76344: you can't access $wgUser during the CentralAuthAutoCreate hoo...tstarling06:10, 22 September 2011
r97797Remove unused global added during testing.tstarling06:28, 22 September 2011

Status & tagging log