* List of Api Query prop modules
* @var array
*/
- private static $QueryPropModules = array(
+ private static $QueryPropModules = [
'categories' => 'ApiQueryCategories',
'categoryinfo' => 'ApiQueryCategoryInfo',
'contributors' => 'ApiQueryContributors',
'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',
'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
private $mPageSet;
private $mParams;
- private $mNamedDB = array();
+ private $mNamedDB = [];
private $mModuleMgr;
/**
$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 );
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
*/
$this->mParams = $this->extractRequestParams();
// Instantiate requested modules
- $allModules = array();
+ $allModules = [];
$this->instantiateModules( $allModules, 'prop' );
$propModules = array_keys( $allModules );
$this->instantiateModules( $allModules, 'list' );
$cacheMode = $this->mergeCacheMode(
$cacheMode, $module->getCacheMode( $params ) );
$module->execute();
- Hooks::run( 'APIQueryAfterExecute', array( &$module ) );
+ Hooks::run( 'APIQueryAfterExecute', [ &$module ] );
}
// Set the cache mode
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 ) ) {
}
// 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() &&
// 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;
}
}
- /**
- * 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();
$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 );
}
* @return string
*/
private function makeHelpMsgHelper( $group ) {
- $moduleDescriptions = array();
+ $moduleDescriptions = [];
$moduleNames = $this->mModuleMgr->getNames( $group );
sort( $moduleNames );
}
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',
- );
+ ];
}
}