2020-08-05 16:02:05 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-09-23 15:10:58 +00:00
|
|
|
* Job that initializes an user's edit count.
|
|
|
|
|
*
|
|
|
|
|
* This is used by UserEditTracker when a user's editcount isn't yet set.
|
2020-08-05 16:02:05 +00:00
|
|
|
*
|
|
|
|
|
* The following job parameters are required:
|
|
|
|
|
* - userId: the user ID
|
|
|
|
|
* - editCount: new edit count to set
|
|
|
|
|
*
|
2022-09-23 15:10:58 +00:00
|
|
|
* @internal For use by \MediaWiki\User\UserEditTracker
|
2020-08-05 16:02:05 +00:00
|
|
|
* @since 1.36
|
|
|
|
|
*/
|
|
|
|
|
class UserEditCountInitJob extends Job implements GenericParameterJob {
|
|
|
|
|
|
|
|
|
|
public function __construct( array $params ) {
|
|
|
|
|
parent::__construct( 'userEditCountInit', $params );
|
2020-08-12 01:35:55 +00:00
|
|
|
$this->removeDuplicates = true;
|
2020-08-05 16:02:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function run() {
|
2024-01-22 21:27:45 +00:00
|
|
|
$dbw = MediaWikiServices::getInstance()->getConnectionProvider()->getPrimaryDatabase();
|
2020-08-05 16:02:05 +00:00
|
|
|
|
2023-06-07 22:07:31 +00:00
|
|
|
$dbw->newUpdateQueryBuilder()
|
|
|
|
|
->update( 'user' )
|
|
|
|
|
->set( [ 'user_editcount' => $this->params['editCount'] ] )
|
|
|
|
|
->where( [
|
2020-08-05 16:02:05 +00:00
|
|
|
'user_id' => $this->params['userId'],
|
2023-10-21 11:32:26 +00:00
|
|
|
$dbw->expr( 'user_editcount', '=', null )->or( 'user_editcount', '<', $this->params['editCount'] )
|
2023-06-07 22:07:31 +00:00
|
|
|
] )
|
|
|
|
|
->caller( __METHOD__ )->execute();
|
2020-08-05 16:02:05 +00:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|