Handle cache invalidation properly for UserIdentity

invalidateCache is not available on UserIdentity

Change-Id: Icb15d4319985b8aae7e2146b6dce87a00f9a91bb
这个提交包含在:
xtex 2024-04-05 22:58:51 +08:00
父节点 109777ed9d
当前提交 c60f03654a
找不到此签名对应的密钥
GPG 密钥 ID: B918086ED8045B91
共有 1 个文件被更改,包括 7 次插入1 次删除

查看文件

@ -1,6 +1,7 @@
<?php
use MediaWiki\MediaWikiServices;
use MediaWiki\User\UserFactory;
use MediaWiki\User\UserIdentity;
/**
@ -74,7 +75,12 @@ class GlobalUserrights extends UserrightsPage {
$newUGMs = GlobalUserrightsHooks::getGroupMemberships( $uid );
// Ensure that caches are cleared
$user->invalidateCache();
if ( method_exists( UserFactory::class, 'invalidateCache' ) ) {
// MW 1.41+
MediaWikiServices::getInstance()->getUserFactory()->invalidateCache( $user );
} else {
$user->invalidateCache();
}
wfDebug( 'oldGlobalGroups: ' . print_r( $oldGroups, true ) . "\n" );
wfDebug( 'newGlobalGroups: ' . print_r( $newGroups, true ) . "\n" );