X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQuery.php;h=43369074ea35d7213d1604f3cdd6106cd0970752;hb=953932c621f24efc06760c430fdbadce21e8767b;hp=8015d65bb98728e4f94711c2a4fb2bf79a489485;hpb=fa7279c78d5b8460668d293e5fac226689bccdb5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index 8015d65bb9..43369074ea 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -41,7 +41,7 @@ class ApiQuery extends ApiBase { * List of Api Query prop modules * @var array */ - private static $QueryPropModules = array( + private static $QueryPropModules = [ 'categories' => 'ApiQueryCategories', 'categoryinfo' => 'ApiQueryCategoryInfo', 'contributors' => 'ApiQueryContributors', @@ -62,13 +62,13 @@ class ApiQuery extends ApiBase { 'stashimageinfo' => 'ApiQueryStashImageInfo', 'templates' => 'ApiQueryLinks', 'transcludedin' => 'ApiQueryBacklinksprop', - ); + ]; /** * List of Api Query list modules * @var array */ - private static $QueryListModules = array( + private static $QueryListModules = [ 'allcategories' => 'ApiQueryAllCategories', 'alldeletedrevisions' => 'ApiQueryAllDeletedRevisions', 'allfileusages' => 'ApiQueryAllLinks', @@ -104,19 +104,19 @@ class ApiQuery extends ApiBase { 'users' => 'ApiQueryUsers', 'watchlist' => 'ApiQueryWatchlist', 'watchlistraw' => 'ApiQueryWatchlistRaw', - ); + ]; /** * List of Api Query meta modules * @var array */ - private static $QueryMetaModules = array( + private static $QueryMetaModules = [ 'allmessages' => 'ApiQueryAllMessages', 'siteinfo' => 'ApiQuerySiteinfo', 'userinfo' => 'ApiQueryUserInfo', 'filerepoinfo' => 'ApiQueryFileRepoInfo', 'tokens' => 'ApiQueryTokens', - ); + ]; /** * @var ApiPageSet @@ -124,7 +124,7 @@ class ApiQuery extends ApiBase { private $mPageSet; private $mParams; - private $mNamedDB = array(); + private $mNamedDB = []; private $mModuleMgr; /** @@ -145,7 +145,7 @@ class ApiQuery extends ApiBase { $this->mModuleMgr->addModules( self::$QueryMetaModules, 'meta' ); $this->mModuleMgr->addModules( $config->get( 'APIMetaModules' ), 'meta' ); - Hooks::run( 'ApiQuery::moduleManager', array( $this->mModuleMgr ) ); + Hooks::run( 'ApiQuery::moduleManager', [ $this->mModuleMgr ] ); // Create PageSet that will process titles/pageids/revids/generator $this->mPageSet = new ApiPageSet( $this ); @@ -185,33 +185,6 @@ class ApiQuery extends ApiBase { return $this->mPageSet; } - /** - * Get the generators array mapping module names to class names - * @deprecated since 1.21, list of generators is maintained by ApiPageSet - * @return array Array(modulename => classname) - */ - public function getGenerators() { - wfDeprecated( __METHOD__, '1.21' ); - $gens = array(); - foreach ( $this->mModuleMgr->getNamesWithClasses() as $name => $class ) { - if ( is_subclass_of( $class, 'ApiQueryGeneratorBase' ) ) { - $gens[$name] = $class; - } - } - - return $gens; - } - - /** - * Get whether the specified module is a prop, list or a meta query module - * @deprecated since 1.21, use getModuleManager()->getModuleGroup() - * @param string $moduleName Name of the module to find type for - * @return string|null - */ - function getModuleType( $moduleName ) { - return $this->getModuleManager()->getModuleGroup( $moduleName ); - } - /** * @return ApiFormatRaw|null */ @@ -241,7 +214,7 @@ class ApiQuery extends ApiBase { $this->mParams = $this->extractRequestParams(); // Instantiate requested modules - $allModules = array(); + $allModules = []; $this->instantiateModules( $allModules, 'prop' ); $propModules = array_keys( $allModules ); $this->instantiateModules( $allModules, 'list' ); @@ -275,7 +248,7 @@ class ApiQuery extends ApiBase { $cacheMode = $this->mergeCacheMode( $cacheMode, $module->getCacheMode( $params ) ); $module->execute(); - Hooks::run( 'APIQueryAfterExecute', array( &$module ) ); + Hooks::run( 'APIQueryAfterExecute', [ &$module ] ); } // Set the cache mode @@ -331,7 +304,7 @@ class ApiQuery extends ApiBase { ApiBase::dieDebug( __METHOD__, 'Error instantiating module' ); } if ( !$wasPosted && $instance->mustBePosted() ) { - $this->dieUsageMsgOrDebug( array( 'mustbeposted', $moduleName ) ); + $this->dieUsageMsgOrDebug( [ 'mustbeposted', $moduleName ] ); } // Ignore duplicates. TODO 2.0: die()? if ( !array_key_exists( $moduleName, $modules ) ) { @@ -376,30 +349,30 @@ class ApiQuery extends ApiBase { } // Page elements - $pages = array(); + $pages = []; // Report any missing titles foreach ( $pageSet->getMissingTitles() as $fakeId => $title ) { - $vals = array(); + $vals = []; ApiQueryBase::addTitleInfo( $vals, $title ); $vals['missing'] = true; $pages[$fakeId] = $vals; } // Report any invalid titles foreach ( $pageSet->getInvalidTitlesAndReasons() as $fakeId => $data ) { - $pages[$fakeId] = $data + array( 'invalid' => true ); + $pages[$fakeId] = $data + [ 'invalid' => true ]; } // Report any missing page ids foreach ( $pageSet->getMissingPageIDs() as $pageid ) { - $pages[$pageid] = array( + $pages[$pageid] = [ 'pageid' => $pageid, 'missing' => true - ); + ]; } // Report special pages /** @var $title Title */ foreach ( $pageSet->getSpecialTitles() as $fakeId => $title ) { - $vals = array(); + $vals = []; ApiQueryBase::addTitleInfo( $vals, $title ); $vals['special'] = true; if ( $title->isSpecialPage() && @@ -416,7 +389,7 @@ class ApiQuery extends ApiBase { // Output general page information for found titles foreach ( $pageSet->getGoodTitles() as $pageid => $title ) { - $vals = array(); + $vals = []; $vals['pageid'] = $pageid; ApiQueryBase::addTitleInfo( $vals, $title ); $pages[$pageid] = $vals; @@ -451,28 +424,12 @@ class ApiQuery extends ApiBase { } } - /** - * This method is called by the generator base when generator in the smart-continue - * mode tries to set 'query-continue' value. ApiQuery stores those values separately - * until the post-processing when it is known if the generation should continue or repeat. - * @deprecated since 1.24 - * @param ApiQueryGeneratorBase $module Generator module - * @param string $paramName - * @param mixed $paramValue - * @return bool True if processed, false if this is a legacy continue - */ - public function setGeneratorContinue( $module, $paramName, $paramValue ) { - wfDeprecated( __METHOD__, '1.24' ); - $this->getContinuationManager()->addGeneratorContinueParam( $module, $paramName, $paramValue ); - return !$this->getParameter( 'rawcontinue' ); - } - /** * @param ApiPageSet $pageSet Pages to be exported * @param ApiResult $result Result to output to */ private function doExport( $pageSet, $result ) { - $exportTitles = array(); + $exportTitles = []; $titles = $pageSet->getGoodTitles(); if ( count( $titles ) ) { $user = $this->getUser(); @@ -506,33 +463,33 @@ class ApiQuery extends ApiBase { $result->addValue( null, 'mime', 'text/xml', ApiResult::NO_SIZE_CHECK ); } else { $result->addValue( 'query', 'export', $exportxml, ApiResult::NO_SIZE_CHECK ); - $result->addValue( 'query', ApiResult::META_BC_SUBELEMENTS, array( 'export' ) ); + $result->addValue( 'query', ApiResult::META_BC_SUBELEMENTS, [ 'export' ] ); } } public function getAllowedParams( $flags = 0 ) { - $result = array( - 'prop' => array( + $result = [ + 'prop' => [ ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => 'submodule', - ), - 'list' => array( + ], + 'list' => [ ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => 'submodule', - ), - 'meta' => array( + ], + 'meta' => [ ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => 'submodule', - ), + ], 'indexpageids' => false, 'export' => false, 'exportnowrap' => false, 'iwurl' => false, - 'continue' => array( + 'continue' => [ ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', - ), + ], 'rawcontinue' => false, - ); + ]; if ( $flags ) { $result += $this->getPageSet()->getFinalParams( $flags ); } @@ -571,7 +528,7 @@ class ApiQuery extends ApiBase { * @return string */ private function makeHelpMsgHelper( $group ) { - $moduleDescriptions = array(); + $moduleDescriptions = []; $moduleNames = $this->mModuleMgr->getNames( $group ); sort( $moduleNames ); @@ -596,21 +553,21 @@ class ApiQuery extends ApiBase { } protected function getExamplesMessages() { - return array( + return [ 'action=query&prop=revisions&meta=siteinfo&' . 'titles=Main%20Page&rvprop=user|comment&continue=' => 'apihelp-query-example-revisions', 'action=query&generator=allpages&gapprefix=API/&prop=revisions&continue=' => 'apihelp-query-example-allpages', - ); + ]; } public function getHelpUrls() { - return array( + return [ 'https://www.mediawiki.org/wiki/API:Query', 'https://www.mediawiki.org/wiki/API:Meta', 'https://www.mediawiki.org/wiki/API:Properties', 'https://www.mediawiki.org/wiki/API:Lists', - ); + ]; } }