Fix PhanTypeMismatchDeclaredParam
[lhc/web/wiklou.git] / includes / api / ApiQueryRecentChanges.php
index 9ff4149..f870d45 100644 (file)
@@ -136,7 +136,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
        /**
         * Generates and outputs the result of this query based upon the provided parameters.
         *
-        * @param ApiPageSet $resultPageSet
+        * @param ApiPageSet|null $resultPageSet
         */
        public function run( $resultPageSet = null ) {
                $user = $this->getUser();
@@ -181,6 +181,16 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                        }
                }
 
+               $title = $params['title'];
+               if ( !is_null( $title ) ) {
+                       $titleObj = Title::newFromText( $title );
+                       if ( is_null( $titleObj ) ) {
+                               $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $title ) ] );
+                       }
+                       $this->addWhereFld( 'rc_namespace', $titleObj->getNamespace() );
+                       $this->addWhereFld( 'rc_title', $titleObj->getDBkey() );
+               }
+
                if ( !is_null( $params['show'] ) ) {
                        $show = array_flip( $params['show'] );
 
@@ -235,15 +245,21 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                        if ( isset( $show['unpatrolled'] ) ) {
                                // See ChangesList::isUnpatrolled
                                if ( $user->useRCPatrol() ) {
-                                       $this->addWhere( 'rc_patrolled = 0' );
+                                       $this->addWhere( 'rc_patrolled = ' . RecentChange::PRC_UNPATROLLED );
                                } elseif ( $user->useNPPatrol() ) {
-                                       $this->addWhere( 'rc_patrolled = 0' );
+                                       $this->addWhere( 'rc_patrolled = ' . RecentChange::PRC_UNPATROLLED );
                                        $this->addWhereFld( 'rc_type', RC_NEW );
                                }
                        }
 
-                       $this->addWhereIf( 'rc_patrolled != 2', isset( $show['!autopatrolled'] ) );
-                       $this->addWhereIf( 'rc_patrolled = 2', isset( $show['autopatrolled'] ) );
+                       $this->addWhereIf(
+                               'rc_patrolled != ' . RecentChange::PRC_AUTOPATROLLED,
+                               isset( $show['!autopatrolled'] )
+                       );
+                       $this->addWhereIf(
+                               'rc_patrolled = ' . RecentChange::PRC_AUTOPATROLLED,
+                               isset( $show['autopatrolled'] )
+                       );
 
                        // Don't throw log entries out the window here
                        $this->addWhereIf(
@@ -552,9 +568,9 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
 
                /* Add the patrolled flag */
                if ( $this->fld_patrolled ) {
-                       $vals['patrolled'] = $row->rc_patrolled != 0;
+                       $vals['patrolled'] = $row->rc_patrolled != RecentChange::PRC_UNPATROLLED;
                        $vals['unpatrolled'] = ChangesList::isUnpatrolled( $row, $user );
-                       $vals['autopatrolled'] = $row->rc_patrolled == 2;
+                       $vals['autopatrolled'] = $row->rc_patrolled == RecentChange::PRC_AUTOPATROLLED;
                }
 
                if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
@@ -721,6 +737,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                                ApiBase::PARAM_TYPE => RecentChange::getChangeTypes()
                        ],
                        'toponly' => false,
+                       'title' => null,
                        'continue' => [
                                ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
                        ],