mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-27 15:30:42 +00:00
Fix fatal when computing user_editcount for anons
UserEditTracker checks that the user is not anonymous, whereas User::getEditCount() would just return null. This was not spotted by tests because UserEditTracker is mocked. Bug: T277859 Follow-up: I8a55bd5cb17bbc259ec36c40261058e0b46ee4a6 Change-Id: I05fb6cc780c80b72b3278e6dc670ed2025628ffb
This commit is contained in:
parent
fa8358ce0c
commit
8b81df4d16
|
@ -13,6 +13,7 @@ use MediaWiki\Storage\RevisionLookup;
|
|||
use MediaWiki\Storage\RevisionStore;
|
||||
use MediaWiki\User\UserEditTracker;
|
||||
use MediaWiki\User\UserGroupManager;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use MWException;
|
||||
use Parser;
|
||||
use ParserOptions;
|
||||
|
@ -297,9 +298,11 @@ class LazyVariableComputer {
|
|||
$result = $title->getRestrictions( $action );
|
||||
break;
|
||||
case 'user-editcount':
|
||||
/** @var UserIdentity $user */
|
||||
/** @var UserIdentity $userIdentity */
|
||||
$userIdentity = $parameters['user-identity'];
|
||||
$result = $this->userEditTracker->getUserEditCount( $userIdentity );
|
||||
$result = $userIdentity->isRegistered()
|
||||
? $this->userEditTracker->getUserEditCount( $userIdentity )
|
||||
: null;
|
||||
break;
|
||||
case 'user-emailconfirm':
|
||||
/** @var User $user */
|
||||
|
@ -307,12 +310,12 @@ class LazyVariableComputer {
|
|||
$result = $user->getEmailAuthenticationTimestamp();
|
||||
break;
|
||||
case 'user-groups':
|
||||
/** @var UserIdentity $user */
|
||||
/** @var UserIdentity $userIdentity */
|
||||
$userIdentity = $parameters['user-identity'];
|
||||
$result = $this->userGroupManager->getUserEffectiveGroups( $userIdentity );
|
||||
break;
|
||||
case 'user-rights':
|
||||
/** @var UserIdentity $user */
|
||||
/** @var UserIdentity $userIdentity */
|
||||
$userIdentity = $parameters['user-identity'];
|
||||
$result = $this->permissionManager->getUserPermissions( $userIdentity );
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue