/**
* @param User $user The user to set the timestamp for
- * @param string $timestamp Set the update timestamp to this value
+ * @param string|null $timestamp Set the update timestamp to this value
* @param LinkTarget[] $targets List of targets to update. Default to all targets
*
* @return bool success
$conds[] = $batch->constructSet( 'wl', $dbw );
}
+ if ( $timestamp !== null ) {
+ $timestamp = $dbw->timestamp( $timestamp );
+ }
+
$success = $dbw->update(
'watchlist',
- [ 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp ) ],
+ [ 'wl_notificationtimestamp' => $timestamp ],
$conds,
__METHOD__
);
);
}
+ public function testSetNotificationTimestampsForUser_nullTimestamp() {
+ $user = $this->getMockNonAnonUserWithId( 1 );
+ $timestamp = null;
+
+ $mockDb = $this->getMockDb();
+ $mockDb->expects( $this->once() )
+ ->method( 'update' )
+ ->with(
+ 'watchlist',
+ [ 'wl_notificationtimestamp' => null ],
+ [ 'wl_user' => 1 ]
+ )
+ ->will( $this->returnValue( true ) );
+ $mockDb->expects( $this->exactly( 0 ) )
+ ->method( 'timestamp' )
+ ->will( $this->returnCallback( function( $value ) {
+ return 'TS' . $value . 'TS';
+ } ) );
+
+ $store = $this->newWatchedItemStore(
+ $this->getMockLoadBalancer( $mockDb ),
+ $this->getMockCache()
+ );
+
+ $this->assertTrue(
+ $store->setNotificationTimestampsForUser( $user, $timestamp )
+ );
+ }
+
public function testSetNotificationTimestampsForUser_specificTargets() {
$user = $this->getMockNonAnonUserWithId( 1 );
$timestamp = '20100101010101';