Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 50 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
| ApiQueryAllCategories | |
0.00% |
0 / 49 |
|
0.00% |
0 / 8 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| execute | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getCacheMode | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| executeGenerator | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| run | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| getAllowedParams | |
0.00% |
0 / 34 |
|
0.00% |
0 / 1 |
2 | |||
| getExamplesMessages | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| getHelpUrls | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Copyright © 2007 Roan Kattouw <roan.kattouw@gmail.com> |
| 4 | * |
| 5 | * @license GPL-2.0-or-later |
| 6 | * @file |
| 7 | */ |
| 8 | |
| 9 | namespace MediaWiki\Api; |
| 10 | |
| 11 | use Wikimedia\ParamValidator\ParamValidator; |
| 12 | use Wikimedia\ParamValidator\TypeDef\IntegerDef; |
| 13 | |
| 14 | /** |
| 15 | * Query module to enumerate all categories, even the ones that don't have |
| 16 | * category pages. |
| 17 | * |
| 18 | * @ingroup API |
| 19 | */ |
| 20 | class ApiQueryAllCategories extends ApiQueryCategoryList { |
| 21 | |
| 22 | public function __construct( ApiQuery $query, string $moduleName ) { |
| 23 | parent::__construct( $query, $moduleName, 'ac' ); |
| 24 | } |
| 25 | |
| 26 | public function execute() { |
| 27 | $this->run(); |
| 28 | } |
| 29 | |
| 30 | /** @inheritDoc */ |
| 31 | public function getCacheMode( $params ) { |
| 32 | return 'public'; |
| 33 | } |
| 34 | |
| 35 | /** @inheritDoc */ |
| 36 | public function executeGenerator( $resultPageSet ) { |
| 37 | $this->run( $resultPageSet ); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @param ApiPageSet|null $resultPageSet |
| 42 | */ |
| 43 | private function run( $resultPageSet = null ) { |
| 44 | $db = $this->getDB(); |
| 45 | $params = $this->extractRequestParams(); |
| 46 | |
| 47 | $this->createQuery( $db, $params ); |
| 48 | $this->executeQuery( $params, $resultPageSet ); |
| 49 | } |
| 50 | |
| 51 | /** @inheritDoc */ |
| 52 | public function getAllowedParams() { |
| 53 | return [ |
| 54 | 'from' => null, |
| 55 | 'continue' => [ |
| 56 | ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', |
| 57 | ], |
| 58 | 'to' => null, |
| 59 | 'prefix' => null, |
| 60 | 'dir' => [ |
| 61 | ParamValidator::PARAM_DEFAULT => 'ascending', |
| 62 | ParamValidator::PARAM_TYPE => [ |
| 63 | 'ascending', |
| 64 | 'descending' |
| 65 | ], |
| 66 | ], |
| 67 | 'min' => [ |
| 68 | ParamValidator::PARAM_TYPE => 'integer' |
| 69 | ], |
| 70 | 'max' => [ |
| 71 | ParamValidator::PARAM_TYPE => 'integer' |
| 72 | ], |
| 73 | 'limit' => [ |
| 74 | ParamValidator::PARAM_DEFAULT => 10, |
| 75 | ParamValidator::PARAM_TYPE => 'limit', |
| 76 | IntegerDef::PARAM_MIN => 1, |
| 77 | IntegerDef::PARAM_MAX => ApiBase::LIMIT_BIG1, |
| 78 | IntegerDef::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
| 79 | ], |
| 80 | 'prop' => [ |
| 81 | ParamValidator::PARAM_TYPE => [ 'size', 'hidden' ], |
| 82 | ParamValidator::PARAM_DEFAULT => '', |
| 83 | ParamValidator::PARAM_ISMULTI => true, |
| 84 | ApiBase::PARAM_HELP_MSG_PER_VALUE => [], |
| 85 | ], |
| 86 | ]; |
| 87 | } |
| 88 | |
| 89 | /** @inheritDoc */ |
| 90 | protected function getExamplesMessages() { |
| 91 | return [ |
| 92 | 'action=query&list=allcategories&acprop=size' |
| 93 | => 'apihelp-query+allcategories-example-size', |
| 94 | 'action=query&generator=allcategories&gacprefix=List&prop=info' |
| 95 | => 'apihelp-query+allcategories-example-generator', |
| 96 | ]; |
| 97 | } |
| 98 | |
| 99 | /** @inheritDoc */ |
| 100 | public function getHelpUrls() { |
| 101 | return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allcategories'; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | /** @deprecated class alias since 1.43 */ |
| 106 | class_alias( ApiQueryAllCategories::class, 'ApiQueryAllCategories' ); |