MediaWiki master
MediaWiki\User\UserEditTracker Class Reference

Track info about user edit counts and timings. More...

Public Member Functions

 __construct (private readonly ActorNormalization $actorNormalization, private readonly IConnectionProvider $dbProvider, private readonly JobQueueGroup $jobQueueGroup, private readonly WANObjectCache $wanObjectCache,)
 
 clearUserEditCache (UserIdentity $user)
 
 getFirstEditTimestamp (UserIdentity $user, int $flags=IDBAccessObject::READ_NORMAL)
 Get the user's first edit timestamp.
 
 getLatestEditTimestamp (UserIdentity $user, int $flags=IDBAccessObject::READ_NORMAL)
 Get the user's latest edit timestamp.
 
 getUserEditCount (UserIdentity $user)
 Get a user's edit count from the user_editcount field, falling back to initialize.
 
 incrementUserEditCount (UserIdentity $user)
 Schedule a job to increase a user's edit count.
 
 initializeUserEditCount (UserIdentity $user)
 
 invalidateCachedFirstEditTimestamps (array $users)
 Invalidates the timestamps of the first edits by users, if they are equal to the timestamps passed together with users.
 
 preloadUserEditCountCache (array $users)
 Preloads the internal edit count cache for the given users.
 
 setCachedUserEditCount (UserIdentity $user, int $editCount)
 

Detailed Description

Track info about user edit counts and timings.

Since
1.35
Author
DannyS712

Definition at line 26 of file UserEditTracker.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\UserEditTracker::__construct ( private readonly ActorNormalization $actorNormalization,
private readonly IConnectionProvider $dbProvider,
private readonly JobQueueGroup $jobQueueGroup,
private readonly WANObjectCache $wanObjectCache )

Definition at line 37 of file UserEditTracker.php.

Member Function Documentation

◆ clearUserEditCache()

MediaWiki\User\UserEditTracker::clearUserEditCache ( UserIdentity $user)
Access: internal
For use by User::clearInstanceCache()
Parameters
UserIdentity$user

Definition at line 272 of file UserEditTracker.php.

References MediaWiki\User\UserIdentity\isRegistered().

◆ getFirstEditTimestamp()

MediaWiki\User\UserEditTracker::getFirstEditTimestamp ( UserIdentity $user,
int $flags = IDBAccessObject::READ_NORMAL )

Get the user's first edit timestamp.

First edit timestamp is fairly immutable and therefore it's cached. If you need to obtain uncached data, use $flags different from READ_NORMAL.

Parameters
UserIdentity$user
int$flagsbit field, see IDBAccessObject::READ_XXX
Returns
string|false Timestamp of first edit, or false for non-existent/anonymous user accounts.

Definition at line 182 of file UserEditTracker.php.

◆ getLatestEditTimestamp()

MediaWiki\User\UserEditTracker::getLatestEditTimestamp ( UserIdentity $user,
int $flags = IDBAccessObject::READ_NORMAL )

Get the user's latest edit timestamp.

Parameters
UserIdentity$user
int$flagsbit field, see IDBAccessObject::READ_XXX
Returns
string|false Timestamp of latest edit, or false for non-existent/anonymous user accounts.

Definition at line 230 of file UserEditTracker.php.

◆ getUserEditCount()

MediaWiki\User\UserEditTracker::getUserEditCount ( UserIdentity $user)

Get a user's edit count from the user_editcount field, falling back to initialize.

Parameters
UserIdentity$user
Returns
int|null Null for anonymous users

Definition at line 51 of file UserEditTracker.php.

◆ incrementUserEditCount()

MediaWiki\User\UserEditTracker::incrementUserEditCount ( UserIdentity $user)

Schedule a job to increase a user's edit count.

Since
1.37
Parameters
UserIdentity$user

Definition at line 161 of file UserEditTracker.php.

References MediaWiki\User\UserIdentity\isRegistered().

◆ initializeUserEditCount()

MediaWiki\User\UserEditTracker::initializeUserEditCount ( UserIdentity $user)
Access: internal
For use in UserEditCountUpdate class
Parameters
UserIdentity$user
Returns
int

Definition at line 132 of file UserEditTracker.php.

◆ invalidateCachedFirstEditTimestamps()

MediaWiki\User\UserEditTracker::invalidateCachedFirstEditTimestamps ( array $users)

Invalidates the timestamps of the first edits by users, if they are equal to the timestamps passed together with users.

Parameters
array<array{0:UserIdentity,1:string|false}>$users Array of pairs (UserIdentity, timestamp).

Definition at line 301 of file UserEditTracker.php.

References MediaWiki\User\UserIdentity\isRegistered().

◆ preloadUserEditCountCache()

MediaWiki\User\UserEditTracker::preloadUserEditCountCache ( array $users)

Preloads the internal edit count cache for the given users.

Use this when calls to self::getUserEditCount() are expected for multiple users, so that the queries can be batched instead of performing one query per user.

Unlike self::getUserEditCount(), this will not try to update the edit counts stored in user_editcount for users for which the count was not previously initialized.

Parameters
UserIdentity[]$users
Since
1.46
Returns
void

Definition at line 93 of file UserEditTracker.php.

References MediaWiki\DAO\WikiAwareEntity\LOCAL.

◆ setCachedUserEditCount()

MediaWiki\User\UserEditTracker::setCachedUserEditCount ( UserIdentity $user,
int $editCount )
Access: internal
For use by User::loadFromRow() and tests
Parameters
UserIdentity$user
int$editCount
Exceptions
InvalidArgumentExceptionIf the user is not registered

Definition at line 287 of file UserEditTracker.php.

References MediaWiki\User\UserIdentity\isRegistered().


The documentation for this class was generated from the following file: