r97796 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97795‎ | r97796 | r97797 >
Date:06:19, 22 September 2011
Author:tstarling
Status:ok
Tags:
Comment:
Add another hook parameter and extensive documentation to CentralAuthAutoCreate in an attempt to avoid a repeat of the half-initialised User issues as fixed by r97794.
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuthHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/CentralAuthHooks.php
@@ -461,10 +461,19 @@
462462 return false;
463463 }
464464
465 - // Give other extensions a chance to stop auto creation,
466 - // but they cannot change $userName, because CentralAuth
467 - // expects user names on all wikis are the same.
468 - if ( !wfRunHooks( 'CentralAuthAutoCreate', array( $user, $userName ) ) ) {
 465+ // Give other extensions a chance to stop auto creation, but they cannot
 466+ // change $userName, because CentralAuth expects user names on all wikis
 467+ // are the same.
 468+ //
 469+ // * $user (and usually $wgUser) is the half-created User object and
 470+ // should not be accessed in any way since calling any User methods
 471+ // in its half-initialised state will give incorrect results.
 472+ //
 473+ // * $userName is the new user name
 474+ //
 475+ // * $anon is an anonymous user object which can be safely used for
 476+ // permissions checks.
 477+ if ( !wfRunHooks( 'CentralAuthAutoCreate', array( $user, $userName, $anon ) ) ) {
469478 wfDebug( __METHOD__ . ": denied by other extensions\n" );
470479 return false;
471480 }

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

Status & tagging log