11use Wikimedia\Timestamp\ConvertibleTimestamp;
12use Wikimedia\Timestamp\TimestampFormat as TS;
28 if ( $user->
getId() ) {
36 public function evaluate( stdClass $row, $value ): bool {
40 $firstUnseen = $this->getLatestNotificationTimestamp( $row, $this->user );
41 $seen = $firstUnseen ===
null
42 || $firstUnseen > ConvertibleTimestamp::convert( TS::MW, $row->rc_timestamp );
44 return $seen === $value;
50 private function getLatestNotificationTimestamp( stdClass $row, UserIdentity $user ) {
51 if ( $row->rc_title ===
'' ) {
54 return $this->watchedItemStore->getLatestNotificationTimestamp(
55 $row->wl_notificationtimestamp,
57 new PageReferenceValue( (
int)$row->rc_namespace, $row->rc_title, PageReferenceValue::LOCAL )
66 if ( !is_bool( $value ) ) {
67 throw new \InvalidArgumentException(
68 'filter "seen" requires a boolean value' );
77 $query->
fields( [
'rc_timestamp',
'rc_namespace',
'rc_title',
'wl_notificationtimestamp' ] );
83 $values = $this->getEnumValues( [
true,
false ] );
84 if ( $values === [] ) {
86 } elseif ( $values === [
true ] ) {
90 $query->
where( $dbr->
expr(
'wl_notificationtimestamp',
'=',
null )
91 ->orExpr(
new RawSQLExpression(
'rc_timestamp < wl_notificationtimestamp' ) ) );
95 } elseif ( $values === [
false ] ) {
99 $query->
where( $dbr->
expr(
'wl_notificationtimestamp',
'!=',
null )
100 ->andExpr(
new RawSQLExpression(
'rc_timestamp >= wl_notificationtimestamp' ) ) );
if(!defined('MW_SETUP_CALLBACK'))