X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryRandom.php;h=2e9e2dd500a7554e7421a18f99b5640f1f3a3686;hb=02bb594ac7c92795b9333f9c891c53a0639d31b8;hp=85863abc1cab2c515ea3ed42f8890a60f818a456;hpb=e55ed729c4bc2179fb27de1ce988d3d351acb5a0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryRandom.php b/includes/api/ApiQueryRandom.php index 85863abc1c..2e9e2dd500 100644 --- a/includes/api/ApiQueryRandom.php +++ b/includes/api/ApiQueryRandom.php @@ -1,9 +1,9 @@ run( $resultPageSet ); } + /** + * @param $randstr + * @param $limit + * @param $namespace + * @param $resultPageSet ApiPageSet + * @param $redirect + * @return void + */ protected function prepareQuery( $randstr, $limit, $namespace, &$resultPageSet, $redirect ) { $this->resetQueryParams(); $this->addTables( 'page' ); @@ -63,11 +68,14 @@ if ( !defined( 'MEDIAWIKI' ) ) { } } - protected function runQuery( &$resultPageSet ) { - $db = $this->getDB(); + /** + * @param $resultPageSet ApiPageSet + * @return int + */ + protected function runQuery( $resultPageSet = null ) { $res = $this->select( __METHOD__ ); $count = 0; - while ( $row = $db->fetchObject( $res ) ) { + foreach ( $res as $row ) { $count++; if ( is_null( $resultPageSet ) ) { // Prevent duplicates @@ -87,10 +95,14 @@ if ( !defined( 'MEDIAWIKI' ) ) { $resultPageSet->processDbRow( $row ); } } - $db->freeResult( $res ); + return $count; } + /** + * @param $resultPageSet ApiPageSet + * @return void + */ public function run( $resultPageSet = null ) { $params = $this->extractRequestParams(); $result = $this->getResult(); @@ -120,6 +132,10 @@ if ( !defined( 'MEDIAWIKI' ) ) { return $vals; } + public function getCacheMode( $params ) { + return 'public'; + } + public function getAllowedParams() { return array( 'namespace' => array( @@ -154,11 +170,11 @@ if ( !defined( 'MEDIAWIKI' ) ) { ); } - protected function getExamples() { + public function getExamples() { return 'api.php?action=query&list=random&rnnamespace=0&rnlimit=2'; } public function getVersion() { return __CLASS__ . ': $Id: ApiQueryRandom.php overlordq$'; } -} \ No newline at end of file +}