Always return false on EchoUserNotificationGateway::markRead

Also rename some variables.
$res indicate a ResultSet, not a bool

Change-Id: I4f0276cbe01a0391b4bd2616e111067b40363fea
This commit is contained in:
Umherirrender 2017-10-03 01:07:31 +02:00 committed by Krinkle
parent 5a74bf552a
commit eba147a1b4
3 changed files with 20 additions and 16 deletions

View file

@ -350,7 +350,8 @@ class MWEchoNotifUser {
/**
* Mark one or more notifications read for a user.
* @param array $eventIds Array of event IDs to mark read
* @return bool
* @return bool Returns true when data has been updated in DB, false on
* failure, or when there was nothing to update
*/
public function markRead( $eventIds ) {
$eventIds = array_filter( (array)$eventIds, 'is_numeric' );
@ -358,8 +359,8 @@ class MWEchoNotifUser {
return false;
}
$res = $this->userNotifGateway->markRead( $eventIds );
if ( $res ) {
$updated = $this->userNotifGateway->markRead( $eventIds );
if ( $updated ) {
// Update notification count in cache
$this->resetNotificationCount( DB_MASTER );
@ -376,13 +377,14 @@ class MWEchoNotifUser {
}
}
return $res;
return $updated;
}
/**
* Mark one or more notifications unread for a user.
* @param array $eventIds Array of event IDs to mark unread
* @return bool
* @return bool Returns true when data has been updated in DB, false on
* failure, or when there was nothing to update
*/
public function markUnRead( $eventIds ) {
$eventIds = array_filter( (array)$eventIds, 'is_numeric' );
@ -390,8 +392,8 @@ class MWEchoNotifUser {
return false;
}
$res = $this->userNotifGateway->markUnRead( $eventIds );
if ( $res ) {
$updated = $this->userNotifGateway->markUnRead( $eventIds );
if ( $updated ) {
// Update notification count in cache
$this->resetNotificationCount( DB_MASTER );
@ -408,7 +410,7 @@ class MWEchoNotifUser {
}
}
return $res;
return $updated;
}
/**
@ -450,8 +452,8 @@ class MWEchoNotifUser {
}, $notifs )
);
$res = $this->markRead( $eventIds );
if ( $res ) {
$updated = $this->markRead( $eventIds );
if ( $updated ) {
// Delete records from echo_target_page
/**
* Keep the 'echo_target_page' records so they can be used for moderation.
@ -462,7 +464,7 @@ class MWEchoNotifUser {
}
}
return $res;
return $updated;
}
/**

View file

@ -43,11 +43,12 @@ class EchoUserNotificationGateway {
/**
* Mark notifications as read
* @param array $eventIDs
* @return bool
* @return bool Returns true when data has been updated in DB, false on
* failure, or when there was nothing to update
*/
public function markRead( array $eventIDs ) {
if ( !$eventIDs ) {
return;
return false;
}
$dbw = $this->dbFactory->getEchoDb( DB_MASTER );
@ -67,11 +68,12 @@ class EchoUserNotificationGateway {
/**
* Mark notifications as unread
* @param array $eventIDs
* @return bool
* @return bool Returns true when data has been updated in DB, false on
* failure, or when there was nothing to update
*/
public function markUnRead( array $eventIDs ) {
if ( !$eventIDs ) {
return;
return false;
}
$dbw = $this->dbFactory->getEchoDb( DB_MASTER );

View file

@ -5,7 +5,7 @@ class EchoUserNotificationGatewayTest extends MediaWikiTestCase {
public function testMarkRead() {
// no event ids to mark
$gateway = new EchoUserNotificationGateway( User::newFromId( 1 ), $this->mockMWEchoDbFactory() );
$this->assertNull( $gateway->markRead( [] ) );
$this->assertFalse( $gateway->markRead( [] ) );
// successful update
$gateway = new EchoUserNotificationGateway( User::newFromId( 1 ), $this->mockMWEchoDbFactory( [ 'update' => true ] ) );