look up global user rights also for anon users with name set

This allows autocreation of local accounts to work based on
global rights.

Bug: T316303
Depends-On: I9ffe2d1a59ff8f9b4eb0ab0677c0fdf5200f4b79
Change-Id: I180fe6b197ebd2223f48389b74a40a281d097948
这个提交包含在:
Ariel T. Glenn 2024-04-08 15:34:35 +03:00
父节点 8ae57d61ce
当前提交 d09f24dcec

查看文件

@ -387,10 +387,15 @@ class CentralAuthHooks implements
* @return bool
*/
public function onUserGetRights( $user, &$rights ) {
if ( $user->isRegistered() ) {
// checking rights not just for registered users but also for
// anon (local) users based on name only will allow autocreation of
// local account based on global rights, see T316303
$anonUserOK = MediaWikiServices::getInstance()->getMainConfig()->get( 'CentralAuthStrict' );
if ( $user->canExist() ) {
$centralUser = CentralAuthUser::getInstance( $user );
if ( $centralUser->exists() && $centralUser->isAttached() ) {
if ( $centralUser->exists()
&& ( $centralUser->isAttached() || ( $anonUserOK && !$user->isRegistered() ) ) ) {
$extraRights = $centralUser->getGlobalRights();
$rights = array_merge( $extraRights, $rights );