Merge "Fix deprecated hooks not having a non-deprecated alternative"
[lhc/web/wiklou.git] / includes / api / ApiQueryWatchlist.php
index 9a4dd82..b1b84d8 100644 (file)
@@ -168,6 +168,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                || ( isset( $show['bot'] ) && isset( $show['!bot'] ) )
                                || ( isset( $show['anon'] ) && isset( $show['!anon'] ) )
                                || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) )
+                               || ( isset( $show['unread'] ) && isset( $show['!unread'] ) )
                        ) {
                                $this->dieUsageMsg( 'show' );
                        }
@@ -191,6 +192,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        $this->addWhereIf( 'rc_user != 0', isset( $show['!anon'] ) );
                        $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) );
                        $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) );
+                       $this->addWhereIf( 'wl_notificationtimestamp IS NOT NULL', isset( $show['unread'] ) );
+                       $this->addWhereIf( 'wl_notificationtimestamp IS NULL', isset( $show['!unread'] ) );
                }
 
                if ( !is_null( $params['type'] ) ) {
@@ -221,7 +224,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
                        if ( !$user->isAllowed( 'deletedhistory' ) ) {
                                $bitmask = Revision::DELETED_USER;
-                       } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
+                       } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
                                $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
                        } else {
                                $bitmask = 0;
@@ -235,7 +238,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                // entirely from the watchlist, or someone could guess the title.
                if ( !$user->isAllowed( 'deletedhistory' ) ) {
                        $bitmask = LogPage::DELETED_ACTION;
-               } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
+               } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
                        $bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
                } else {
                        $bitmask = 0;
@@ -490,6 +493,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                        '!anon',
                                        'patrolled',
                                        '!patrolled',
+                                       'unread',
+                                       '!unread',
                                )
                        ),
                        'type' => array(
@@ -557,8 +562,6 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
        }
 
        public function getResultProperties() {
-               global $wgLogTypes;
-
                return array(
                        '' => array(
                                'type' => array(
@@ -627,7 +630,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                        ApiBase::PROP_NULLABLE => true
                                ),
                                'logtype' => array(
-                                       ApiBase::PROP_TYPE => $wgLogTypes,
+                                       ApiBase::PROP_TYPE => $this->getConfig()->get( 'LogTypes' ),
                                        ApiBase::PROP_NULLABLE => true
                                ),
                                'logaction' => array(