48 parent::__construct(
'activityUpdateJob',
$params );
50 static $required = [
'type',
'userid',
'notifTime',
'curTime' ];
51 $missing = implode(
', ', array_diff( $required, array_keys( $this->params ) ) );
52 if ( $missing !=
'' ) {
53 throw new InvalidArgumentException(
"Missing parameter(s) $missing" );
56 $this->removeDuplicates =
true;
59 public function run() {
60 if ( $this->params[
'type'] ===
'updateWatchlistNotification' ) {
63 throw new InvalidArgumentException(
"Invalid 'type' '{$this->params['type']}'." );
70 $casTimestamp = $this->params[
'notifTime'] ?? $this->params[
'curTime'];
79 $casTimeCond = $dbw->buildComparison(
81 [
'wl_notificationtimestamp' => $dbw->timestamp( $casTimestamp ) ]
85 $wlId = $dbw->newSelectQueryBuilder()
89 'wl_user' => $this->params[
'userid'],
90 'wl_namespace' => $this->title->getNamespace(),
91 'wl_title' => $this->title->getDBkey(),
93 ] )->caller( __METHOD__ )->fetchField();
98 $dbw->newUpdateQueryBuilder()
99 ->update(
'watchlist' )
100 ->set( [
'wl_notificationtimestamp' => $dbw->timestampOrNull( $this->params[
'notifTime'] ) ] )
101 ->where( [
'wl_id' => (
int)$wlId, $casTimeCond ] )
102 ->caller( __METHOD__ )->execute();
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Job for updating user activity like "last viewed" timestamps.
updateWatchlistNotification()
__construct( $title, array $params)
Class to both describe a background job and handle jobs.
array $params
Array of job parameters.