X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryRecentChanges.php;h=8b11dc2a47d2169c9976594f48e9ca2a5afd6110;hb=c584722cc2e3d33edae58d46c2149063b3fc6d72;hp=cc3ca60f3dbde42b945d3f06ddd7568b66c0ce52;hpb=43b7b5ef948ede9f1b8dee64b5d8742d4ab292c5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index cc3ca60f3d..26581a62d8 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -147,7 +147,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { /* Build our basic query. Namely, something along the lines of: * SELECT * FROM recentchanges WHERE rc_timestamp > $start - * AND rc_timestamp < $end AND rc_namespace = $namespace + * AND rc_timestamp < $end AND rc_namespace = $namespace */ $this->addTables( 'recentchanges' ); $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] ); @@ -195,7 +195,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { || ( isset( $show['patrolled'] ) && isset( $show['unpatrolled'] ) ) || ( isset( $show['!patrolled'] ) && isset( $show['unpatrolled'] ) ) ) { - $this->dieUsageMsg( 'show' ); + $this->dieWithError( 'apierror-show' ); } // Check permissions @@ -204,10 +204,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { || isset( $show['unpatrolled'] ) ) { if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) { - $this->dieUsage( - 'You need patrol or patrolmarks permission to request the patrolled flag', - 'permissiondenied' - ); + $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' ); } } @@ -239,9 +236,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { ); } - if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) ) { - $this->dieUsage( 'user and excludeuser cannot be used together', 'user-excludeuser' ); - } + $this->requireMaxOneParameter( $params, 'user', 'excludeuser' ); if ( !is_null( $params['user'] ) ) { $this->addWhereFld( 'rc_user_text', $params['user'] ); @@ -274,10 +269,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->initProperties( $prop ); if ( $this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol() ) { - $this->dieUsage( - 'You need patrol or patrolmarks permission to request the patrolled flag', - 'permissiondenied' - ); + $this->dieWithError( 'apierror-permissiondenied-patrolflag', 'permissiondenied' ); } /* Add fields to our query if they are specified as a needed parameter. */ @@ -328,7 +320,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->addWhereFld( 'ct_tag', $params['tag'] ); } - // Paranoia: avoid brute force searches (bug 17342) + // Paranoia: avoid brute force searches (T19342) if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) { if ( !$user->isAllowed( 'deletedhistory' ) ) { $bitmask = Revision::DELETED_USER; @@ -361,9 +353,10 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->token = $params['token']; $this->addOption( 'LIMIT', $params['limit'] + 1 ); + $hookData = []; $count = 0; /* Perform the actual query. */ - $res = $this->select( __METHOD__ ); + $res = $this->select( __METHOD__, [], $hookData ); $revids = []; $titles = []; @@ -372,6 +365,13 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { /* Iterate through the rows, adding data extracted from them to our query result. */ foreach ( $res as $row ) { + if ( $count === 0 && $resultPageSet !== null ) { + // Set the non-continue since the list of recentchanges is + // prone to having entries added at the start frequently. + $this->getContinuationManager()->addGeneratorNonContinueParam( + $this, 'continue', "$row->rc_timestamp|$row->rc_id" + ); + } if ( ++$count > $params['limit'] ) { // We've reached the one extra which shows that there are // additional pages to be had. Stop here... @@ -384,7 +384,8 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $vals = $this->extractRowInfo( $row ); /* Add that row's data to our final output. */ - $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $vals ); + $fit = $this->processRow( $row, $vals, $hookData ) && + $result->addValue( [ 'query', $this->getModuleName() ], null, $vals ); if ( !$fit ) { $this->setContinueEnumParameter( 'continue', "$row->rc_timestamp|$row->rc_id" ); break; @@ -562,7 +563,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $val = call_user_func( $tokenFunctions[$t], $row->rc_cur_id, $title, RecentChange::newFromRow( $row ) ); if ( $val === false ) { - $this->setWarning( "Action '$t' is not allowed for the current user" ); + $this->addWarning( [ 'apiwarn-tokennotallowed', $t ] ); } else { $vals[$t . 'token'] = $val; } @@ -616,7 +617,8 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { ], 'namespace' => [ ApiBase::PARAM_ISMULTI => true, - ApiBase::PARAM_TYPE => 'namespace' + ApiBase::PARAM_TYPE => 'namespace', + ApiBase::PARAM_EXTRA_NAMESPACES => [ NS_MEDIA, NS_SPECIAL ], ], 'user' => [ ApiBase::PARAM_TYPE => 'user'