11use Wikimedia\Timestamp\ConvertibleTimestamp;
12use Wikimedia\Timestamp\TimestampFormat as TS;
30 if ( $user->
getId() ) {
38 public function evaluate( stdClass $row, $value ): bool {
42 $firstUnseen = $this->getLatestNotificationTimestamp( $row, $this->user );
43 $seen = $firstUnseen ===
null
44 || $firstUnseen > ConvertibleTimestamp::convert( TS::MW, $row->rc_timestamp );
46 return $seen === $value;
52 private function getLatestNotificationTimestamp( stdClass $row, UserIdentity $user ) {
53 if ( $row->rc_title ===
'' ) {
56 return $this->watchedItemStore->getLatestNotificationTimestamp(
57 $row->wl_notificationtimestamp,
59 new PageReferenceValue( (
int)$row->rc_namespace, $row->rc_title, PageReferenceValue::LOCAL )
68 if ( !is_bool( $value ) ) {
69 throw new \InvalidArgumentException(
70 'filter "seen" requires a boolean value' );
79 $query->
fields( [
'rc_timestamp',
'rc_namespace',
'rc_title',
'wl_notificationtimestamp' ] );
85 $values = $this->getEnumValues( [
true,
false ] );
86 if ( $values === [] ) {
88 } elseif ( $values === [
true ] ) {
92 $query->
where( $dbr->
expr(
'wl_notificationtimestamp',
'=',
null )
93 ->orExpr(
new RawSQLExpression(
'rc_timestamp < wl_notificationtimestamp' ) ) );
97 } elseif ( $values === [
false ] ) {
101 $query->
where( $dbr->
expr(
'wl_notificationtimestamp',
'!=',
null )
102 ->andExpr(
new RawSQLExpression(
'rc_timestamp >= wl_notificationtimestamp' ) ) );
if(!defined('MW_SETUP_CALLBACK'))