X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryRecentChanges.php;h=1fb2a693b03de5efd0491b60eceb615ff37f8540;hb=ecc71fc9e4bac94a879c0734d90ba0b94211d5d3;hp=80352f2528ebec20bc6c0a8ad1359b206764af1c;hpb=83a1cf573f7439e45d292a072472ac49212c9ffb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 80352f2528..1fb2a693b0 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -32,7 +32,7 @@ */ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { - public function __construct( $query, $moduleName ) { + public function __construct( ApiQuery $query, $moduleName ) { parent::__construct( $query, $moduleName, 'rc' ); } @@ -69,9 +69,9 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { } /** - * @param $pageid - * @param $title - * @param $rc RecentChange (optional) + * @param int $pageid + * @param Title $title + * @param RecentChange|null $rc * @return bool|string */ public static function getPatrolToken( $pageid, $title, $rc = null ) { @@ -135,7 +135,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { /** * Generates and outputs the result of this query based upon the provided parameters. * - * @param $resultPageSet ApiPageSet + * @param ApiPageSet $resultPageSet */ public function run( $resultPageSet = null ) { $user = $this->getUser(); @@ -174,7 +174,11 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->addWhereFld( 'rc_namespace', $params['namespace'] ); if ( !is_null( $params['type'] ) ) { - $this->addWhereFld( 'rc_type', $this->parseRCType( $params['type'] ) ); + try { + $this->addWhereFld( 'rc_type', RecentChange::parseToRCType( $params['type'] ) ); + } catch ( MWException $e ) { + ApiBase::dieDebug( __METHOD__, $e->getMessage() ); + } } if ( !is_null( $params['show'] ) ) { @@ -414,30 +418,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $vals = array(); $type = intval( $row->rc_type ); - - /* Determine what kind of change this was. */ - switch ( $type ) { - case RC_EDIT: - $vals['type'] = 'edit'; - break; - case RC_NEW: - $vals['type'] = 'new'; - break; - case RC_MOVE: - $vals['type'] = 'move'; - break; - case RC_LOG: - $vals['type'] = 'log'; - break; - case RC_EXTERNAL: - $vals['type'] = 'external'; - break; - case RC_MOVE_OVER_REDIRECT: - $vals['type'] = 'move over redirect'; - break; - default: - $vals['type'] = $type; - } + $vals['type'] = RecentChange::parseFromRCType( $type ); $anyHidden = false; @@ -607,30 +588,6 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { return $vals; } - private function parseRCType( $type ) { - if ( is_array( $type ) ) { - $retval = array(); - foreach ( $type as $t ) { - $retval[] = $this->parseRCType( $t ); - } - - return $retval; - } - - switch ( $type ) { - case 'edit': - return RC_EDIT; - case 'new': - return RC_NEW; - case 'log': - return RC_LOG; - case 'external': - return RC_EXTERNAL; - default: - ApiBase::dieDebug( __METHOD__, "Unknown type '$type'" ); - } - } - public function getCacheMode( $params ) { if ( isset( $params['show'] ) ) { foreach ( $params['show'] as $show ) {