wiki.techinc.nl/includes/deferred/UserEditCountInfo.php
Tim Starling 960a7925ae Add hook UserEditCountUpdate
Add a hook which runs at the end of UserEditCountUpdate. The idea is to
allow CentralAuth to keep its own similar edit count. There's no
other hook appropriate for this purpose since
UserEditTracker::incrementUserEditCount() has multiple callers.

Convert the private associative array in UserEditCountUpdate to a class.
Instances of the class are passed to the new hook. A class is better
suited to a public interface.

Bug: T300075
Change-Id: I16a92e6a6e9faf1be4c7fbe25354a08559df163d
2022-01-31 17:00:49 +11:00

51 lines
919 B
PHP

<?php
use MediaWiki\User\UserIdentity;
/**
* Helper class for UserEditCountUpdate
* @since 1.38
*/
class UserEditCountInfo {
/** @var UserIdentity */
private $user;
/** @var int */
private $increment;
/**
* @internal
* @param UserIdentity $user
* @param int $increment
*/
public function __construct( UserIdentity $user, int $increment ) {
$this->user = $user;
$this->increment = $increment;
}
/**
* Merge another UserEditCountInfo into this one
*
* @param UserEditCountInfo $other
*/
public function merge( self $other ) {
if ( !$this->user->equals( $other->user ) ) {
throw new InvalidArgumentException( __METHOD__ . ': user does not match' );
}
$this->increment += $other->increment;
}
/**
* @return UserIdentity
*/
public function getUser() {
return $this->user;
}
/**
* @return int
*/
public function getIncrement() {
return $this->increment;
}
}