3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
21 use MediaWiki\MediaWikiServices
;
24 * Job that initializes an user's edit count.
26 * This is used by UserEditTracker when a user's editcount isn't yet set.
28 * The following job parameters are required:
29 * - userId: the user ID
30 * - editCount: new edit count to set
32 * @internal For use by \MediaWiki\User\UserEditTracker
36 class UserEditCountInitJob
extends Job
implements GenericParameterJob
{
38 public function __construct( array $params ) {
39 parent
::__construct( 'userEditCountInit', $params );
40 $this->removeDuplicates
= true;
43 public function run() {
44 $dbw = MediaWikiServices
::getInstance()->getConnectionProvider()->getPrimaryDatabase();
46 $dbw->newUpdateQueryBuilder()
48 ->set( [ 'user_editcount' => $this->params
['editCount'] ] )
50 'user_id' => $this->params
['userId'],
51 $dbw->expr( 'user_editcount', '=', null )->or( 'user_editcount', '<', $this->params
['editCount'] )
53 ->caller( __METHOD__
)->execute();