Use constants for rc_patrolled values instead of numbers
authorAmir Sarabadani <ladsgroup@gmail.com>
Fri, 13 Apr 2018 21:36:34 +0000 (23:36 +0200)
committerAmir Sarabadani <ladsgroup@gmail.com>
Fri, 13 Apr 2018 21:56:35 +0000 (23:56 +0200)
These are recently introduced, better to use them

Change-Id: Id904ff09081cb5a1fe2f1c24c5d415da18fd2294

includes/Storage/RevisionStore.php
includes/revisiondelete/RevDelLogItem.php
includes/revisiondelete/RevDelRevisionItem.php
includes/specialpage/ChangesListSpecialPage.php
includes/specials/pagers/NewFilesPager.php
includes/specials/pagers/NewPagesPager.php
includes/watcheditem/WatchedItemQueryService.php
tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php

index 584142b..1f0afae 100644 (file)
@@ -636,7 +636,7 @@ class RevisionStore
         */
        public function getRcIdIfUnpatrolled( RevisionRecord $rev ) {
                $rc = $this->getRecentChange( $rev );
-               if ( $rc && $rc->getAttribute( 'rc_patrolled' ) == 0 ) {
+               if ( $rc && $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_UNPATROLLED ) {
                        return $rc->getAttribute( 'rc_id' );
                } else {
                        return 0;
index 198a28b..36198cd 100644 (file)
@@ -75,7 +75,7 @@ class RevDelLogItem extends RevDelItem {
                $dbw->update( 'recentchanges',
                        [
                                'rc_deleted' => $bits,
-                               'rc_patrolled' => 1
+                               'rc_patrolled' => RecentChange::PRC_PATROLLED
                        ],
                        [
                                'rc_logid' => $this->row->log_id,
index cb5ce48..7b5d130 100644 (file)
@@ -83,7 +83,7 @@ class RevDelRevisionItem extends RevDelItem {
                $dbw->update( 'recentchanges',
                        [
                                'rc_deleted' => $bits,
-                               'rc_patrolled' => 1
+                               'rc_patrolled' => RecentChange::PRC_PATROLLED
                        ],
                        [
                                'rc_this_oldid' => $this->revision->getId(), // condition
index 2a4acc8..ac13f11 100644 (file)
@@ -475,7 +475,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                                                'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
                                                        &$query_options, &$join_conds
                                                ) {
-                                                       $conds[] = 'rc_patrolled = 0';
+                                                       $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
                                                },
                                                'isReplacedInStructuredUi' => true,
                                        ],
@@ -485,7 +485,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                                                'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
                                                        &$query_options, &$join_conds
                                                ) {
-                                                       $conds[] = 'rc_patrolled != 0';
+                                                       $conds[] = 'rc_patrolled != ' . RecentChange::PRC_UNPATROLLED;
                                                },
                                                'isReplacedInStructuredUi' => true,
                                        ],
index 57cdad9..c214f1f 100644 (file)
@@ -110,7 +110,7 @@ class NewFilesPager extends RangeChronologicalPager {
                        $tables[] = 'recentchanges';
                        $conds['rc_type'] = RC_LOG;
                        $conds['rc_log_type'] = 'upload';
-                       $conds['rc_patrolled'] = 0;
+                       $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
                        $conds['rc_namespace'] = NS_FILE;
 
                        if ( $wgActorTableSchemaMigrationStage === MIGRATION_NEW ) {
index efdc75a..f16a5cb 100644 (file)
@@ -82,7 +82,7 @@ class NewPagesPager extends ReverseChronologicalPager {
 
                # If this user cannot see patrolled edits or they are off, don't do dumb queries!
                if ( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) {
-                       $conds['rc_patrolled'] = 0;
+                       $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
                }
 
                if ( $this->opts->getValue( 'hidebots' ) ) {
index bf419a9..506ee00 100644 (file)
@@ -498,15 +498,15 @@ class WatchedItemQueryService {
                        // TODO: not sure if this should simply ignore patrolled filters if user does not have the patrol
                        // right, or maybe rather fail loud at this point, same as e.g. ApiQueryWatchlist does?
                        if ( in_array( self::FILTER_PATROLLED, $options['filters'] ) ) {
-                               $conds[] = 'rc_patrolled != 0';
+                               $conds[] = 'rc_patrolled != ' . RecentChange::PRC_UNPATROLLED;
                        } elseif ( in_array( self::FILTER_NOT_PATROLLED, $options['filters'] ) ) {
-                               $conds[] = 'rc_patrolled = 0';
+                               $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
                        }
 
                        if ( in_array( self::FILTER_AUTOPATROLLED, $options['filters'] ) ) {
-                               $conds[] = 'rc_patrolled = 2';
+                               $conds['rc_patrolled'] = RecentChange::PRC_AUTOPATROLLED;
                        } elseif ( in_array( self::FILTER_NOT_AUTOPATROLLED, $options['filters'] ) ) {
-                               $conds[] = 'rc_patrolled != 2';
+                               $conds[] = 'rc_patrolled != ' . RecentChange::PRC_AUTOPATROLLED;
                        }
                }
 
index be51626..50e6c20 100644 (file)
@@ -776,7 +776,7 @@ class WatchedItemQueryServiceUnitTest extends MediaWikiTestCase {
                                null,
                                [],
                                [],
-                               [ 'rc_patrolled = 0' ],
+                               [ 'rc_patrolled' => 0 ],
                                [],
                                [],
                        ],