53 parent::__construct( $query, $moduleName,
'ap' );
54 $this->namespaceInfo = $namespaceInfo;
55 $this->genderCache = $genderCache;
56 $this->restrictionStore = $restrictionStore;
72 if ( $resultPageSet->isResolvingRedirects() ) {
73 $this->
dieWithError(
'apierror-allpages-generator-redirects',
'params' );
76 $this->run( $resultPageSet );
83 private function run( $resultPageSet =
null ) {
91 if ( $params[
'continue'] !==
null ) {
93 $op = $params[
'dir'] ==
'descending' ?
'<=' :
'>=';
94 $this->
addWhere( $db->expr(
'page_title', $op, $cont[0] ) );
99 if ( $params[
'filterredir'] ==
'redirects' ) {
101 } elseif ( $params[
'filterredir'] ==
'nonredirects' ) {
106 $this->
addWhereFld(
'page_namespace', $params[
'namespace'] );
107 $dir = (
$params[
'dir'] ==
'descending' ?
'older' :
'newer' );
108 $from = (
$params[
'from'] ===
null
110 : $this->
titlePartToKey( $params[
'from'], $params[
'namespace'] ) );
116 if ( isset( $params[
'prefix'] ) ) {
121 new LikeValue( $this->
titlePartToKey( $params[
'prefix'], $params[
'namespace'] ), $db->anyString() )
126 if ( $resultPageSet ===
null ) {
133 $selectFields = $resultPageSet->getPageTableFields();
136 $miserModeFilterRedirValue =
null;
137 $miserModeFilterRedir = $miserMode &&
$params[
'filterredir'] !==
'all';
138 if ( $miserModeFilterRedir ) {
139 $selectFields[] =
'page_is_redirect';
141 if ( $params[
'filterredir'] ==
'redirects' ) {
142 $miserModeFilterRedirValue = 1;
143 } elseif ( $params[
'filterredir'] ==
'nonredirects' ) {
144 $miserModeFilterRedirValue = 0;
149 $forceNameTitleIndex =
true;
150 if ( isset( $params[
'minsize'] ) ) {
151 $this->
addWhere(
'page_len>=' . (
int)$params[
'minsize'] );
152 $forceNameTitleIndex =
false;
155 if ( isset( $params[
'maxsize'] ) ) {
156 $this->
addWhere(
'page_len<=' . (
int)$params[
'maxsize'] );
157 $forceNameTitleIndex =
false;
161 if ( $params[
'prtype'] || $params[
'prexpiry'] !=
'all' ) {
163 $this->
addWhere(
'page_id=pr_page' );
165 $db->expr(
'pr_expiry',
'>', $db->timestamp() )->or(
'pr_expiry',
'=',
null )
168 if ( $params[
'prtype'] ) {
169 $this->
addWhereFld(
'pr_type', $params[
'prtype'] );
171 if ( isset( $params[
'prlevel'] ) ) {
173 $prlevel = array_diff( $params[
'prlevel'], [
'',
'*' ] );
175 if ( count( $prlevel ) ) {
179 if ( $params[
'prfiltercascade'] ==
'cascading' ) {
181 } elseif ( $params[
'prfiltercascade'] ==
'noncascading' ) {
185 $forceNameTitleIndex =
false;
187 if ( $params[
'prexpiry'] ==
'indefinite' ) {
188 $this->
addWhereFld(
'pr_expiry', [ $db->getInfinity(),
null ] );
189 } elseif ( $params[
'prexpiry'] ==
'definite' ) {
190 $this->
addWhere( $db->expr(
'pr_expiry',
'!=', $db->getInfinity() ) );
194 } elseif ( isset( $params[
'prlevel'] ) ) {
196 [
'apierror-invalidparammix-mustusewith',
'prlevel',
'prtype' ],
'invalidparammix'
200 if ( $params[
'filterlanglinks'] ==
'withoutlanglinks' ) {
202 $this->
addJoinConds( [
'langlinks' => [
'LEFT JOIN',
'page_id=ll_from' ] ] );
203 $this->
addWhere( [
'll_from' =>
null ] );
204 $forceNameTitleIndex =
false;
205 } elseif ( $params[
'filterlanglinks'] ==
'withlanglinks' ) {
207 $this->
addWhere(
'page_id=ll_from' );
210 $dbType = $db->getType();
211 if ( $dbType ===
'mysql' || $dbType ===
'sqlite' ) {
213 $this->
addOption(
'GROUP BY', [
'page_title' ] );
216 $this->
addOption(
'GROUP BY', [
'page_title',
'page_id' ] );
219 $forceNameTitleIndex =
false;
222 if ( $forceNameTitleIndex ) {
223 $this->
addOption(
'USE INDEX',
'page_name_title' );
228 $res = $this->
select( __METHOD__ );
231 if ( $this->namespaceInfo->hasGenderDistinction( $params[
'namespace'] ) ) {
233 foreach ( $res as $row ) {
234 $users[] = $row->page_title;
236 $this->genderCache->doQuery( $users, __METHOD__ );
242 foreach ( $res as $row ) {
243 if ( ++$count > $limit ) {
250 if ( $miserModeFilterRedir && (
int)$row->page_is_redirect !== $miserModeFilterRedirValue ) {
255 if ( $resultPageSet ===
null ) {
256 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
258 'pageid' => (int)$row->page_id,
259 'ns' => $title->getNamespace(),
260 'title' => $title->getPrefixedText()
262 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
268 $resultPageSet->processDbRow( $row );
272 if ( $resultPageSet ===
null ) {
273 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'p' );
286 ParamValidator::PARAM_DEFAULT =>
NS_MAIN,
287 ParamValidator::PARAM_TYPE =>
'namespace',
290 ParamValidator::PARAM_DEFAULT =>
'all',
291 ParamValidator::PARAM_TYPE => [
297 'filterlanglinks' => [
298 ParamValidator::PARAM_TYPE => [
303 ParamValidator::PARAM_DEFAULT =>
'all'
306 ParamValidator::PARAM_TYPE =>
'integer',
309 ParamValidator::PARAM_TYPE =>
'integer',
312 ParamValidator::PARAM_TYPE => $this->restrictionStore->listAllRestrictionTypes(
true ),
313 ParamValidator::PARAM_ISMULTI => true
316 ParamValidator::PARAM_TYPE =>
318 ParamValidator::PARAM_ISMULTI => true
320 'prfiltercascade' => [
321 ParamValidator::PARAM_DEFAULT =>
'all',
322 ParamValidator::PARAM_TYPE => [
329 ParamValidator::PARAM_TYPE => [
334 ParamValidator::PARAM_DEFAULT =>
'all',
338 ParamValidator::PARAM_DEFAULT => 10,
339 ParamValidator::PARAM_TYPE =>
'limit',
340 IntegerDef::PARAM_MIN => 1,
345 ParamValidator::PARAM_DEFAULT =>
'ascending',
346 ParamValidator::PARAM_TYPE => [
362 'action=query&list=allpages&apfrom=B'
363 =>
'apihelp-query+allpages-example-b',
364 'action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info'
365 =>
'apihelp-query+allpages-example-generator',
366 'action=query&generator=allpages&gaplimit=2&' .
367 'gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content'
368 =>
'apihelp-query+allpages-example-generator-revisions',
373 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allpages';
378class_alias( ApiQueryAllPages::class,
'ApiQueryAllPages' );
Query module to enumerate all available pages.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getExamplesMessages()
Returns usage examples for this module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getHelpUrls()
Return links to more detailed help pages about the module.
__construct(ApiQuery $query, string $moduleName, NamespaceInfo $namespaceInfo, GenderCache $genderCache, RestrictionStore $restrictionStore)
executeGenerator( $resultPageSet)
A class containing constants representing the names of configuration variables.
const RestrictionLevels
Name constant for the RestrictionLevels setting, for use with Config::get()
const MiserMode
Name constant for the MiserMode setting, for use with Config::get()