35 parent::__construct( $query, $moduleName,
'ap' );
52 if ( $resultPageSet->isResolvingRedirects() ) {
53 $this->
dieWithError(
'apierror-allpages-generator-redirects',
'params' );
56 $this->run( $resultPageSet );
63 private function run( $resultPageSet =
null ) {
71 if ( $params[
'continue'] !==
null ) {
73 $op = $params[
'dir'] ==
'descending' ?
'<=' :
'>=';
74 $this->
addWhere( $db->expr(
'page_title', $op, $cont[0] ) );
79 if ( $params[
'filterredir'] ==
'redirects' ) {
81 } elseif ( $params[
'filterredir'] ==
'nonredirects' ) {
86 $this->
addWhereFld(
'page_namespace', $params[
'namespace'] );
87 $dir = (
$params[
'dir'] ==
'descending' ?
'older' :
'newer' );
88 $from = (
$params[
'from'] ===
null
90 : $this->
titlePartToKey( $params[
'from'], $params[
'namespace'] ) );
96 if ( isset( $params[
'prefix'] ) ) {
101 new LikeValue( $this->
titlePartToKey( $params[
'prefix'], $params[
'namespace'] ), $db->anyString() )
106 if ( $resultPageSet ===
null ) {
113 $selectFields = $resultPageSet->getPageTableFields();
116 $miserModeFilterRedirValue =
null;
117 $miserModeFilterRedir = $miserMode &&
$params[
'filterredir'] !==
'all';
118 if ( $miserModeFilterRedir ) {
119 $selectFields[] =
'page_is_redirect';
121 if ( $params[
'filterredir'] ==
'redirects' ) {
122 $miserModeFilterRedirValue = 1;
123 } elseif ( $params[
'filterredir'] ==
'nonredirects' ) {
124 $miserModeFilterRedirValue = 0;
129 $forceNameTitleIndex =
true;
130 if ( isset( $params[
'minsize'] ) ) {
131 $this->
addWhere(
'page_len>=' . (
int)$params[
'minsize'] );
132 $forceNameTitleIndex =
false;
135 if ( !$miserMode && isset( $params[
'maxsize'] ) ) {
136 $this->
addWhere(
'page_len<=' . (
int)$params[
'maxsize'] );
137 $forceNameTitleIndex =
false;
141 if ( $params[
'prtype'] || $params[
'prexpiry'] !=
'all' ) {
143 $this->
addWhere(
'page_id=pr_page' );
145 $db->expr(
'pr_expiry',
'>', $db->timestamp() )->or(
'pr_expiry',
'=',
null )
148 if ( $params[
'prtype'] ) {
149 $this->
addWhereFld(
'pr_type', $params[
'prtype'] );
151 if ( isset( $params[
'prlevel'] ) ) {
153 $prlevel = array_diff( $params[
'prlevel'], [
'',
'*' ] );
155 if ( count( $prlevel ) ) {
159 if ( $params[
'prfiltercascade'] ==
'cascading' ) {
161 } elseif ( $params[
'prfiltercascade'] ==
'noncascading' ) {
165 $forceNameTitleIndex =
false;
167 if ( $params[
'prexpiry'] ==
'indefinite' ) {
168 $this->
addWhereFld(
'pr_expiry', [ $db->getInfinity(),
null ] );
169 } elseif ( $params[
'prexpiry'] ==
'definite' ) {
170 $this->
addWhere( $db->expr(
'pr_expiry',
'!=', $db->getInfinity() ) );
174 } elseif ( isset( $params[
'prlevel'] ) ) {
176 [
'apierror-invalidparammix-mustusewith',
'prlevel',
'prtype' ],
'invalidparammix'
180 if ( $params[
'filterlanglinks'] ==
'withoutlanglinks' ) {
182 $this->
addJoinConds( [
'langlinks' => [
'LEFT JOIN',
'page_id=ll_from' ] ] );
183 $this->
addWhere( [
'll_from' =>
null ] );
184 $forceNameTitleIndex =
false;
185 } elseif ( $params[
'filterlanglinks'] ==
'withlanglinks' ) {
187 $this->
addWhere(
'page_id=ll_from' );
190 $dbType = $db->getType();
191 if ( $dbType ===
'mysql' || $dbType ===
'sqlite' ) {
193 $this->
addOption(
'GROUP BY', [
'page_title' ] );
196 $this->
addOption(
'GROUP BY', [
'page_title',
'page_id' ] );
199 $forceNameTitleIndex =
false;
202 if ( $forceNameTitleIndex ) {
203 $this->
addOption(
'USE INDEX',
'page_name_title' );
208 $res = $this->
select( __METHOD__ );
211 if ( $this->namespaceInfo->hasGenderDistinction( $params[
'namespace'] ) ) {
213 foreach ( $res as $row ) {
214 $users[] = $row->page_title;
216 $this->genderCache->doQuery( $users, __METHOD__ );
222 foreach ( $res as $row ) {
223 if ( ++$count > $limit ) {
230 if ( $miserModeFilterRedir && (
int)$row->page_is_redirect !== $miserModeFilterRedirValue ) {
235 if ( $resultPageSet ===
null ) {
238 'pageid' => (int)$row->page_id,
239 'ns' => $title->getNamespace(),
240 'title' => $title->getPrefixedText()
242 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
248 $resultPageSet->processDbRow( $row );
252 if ( $resultPageSet ===
null ) {
253 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'p' );
267 ParamValidator::PARAM_DEFAULT =>
NS_MAIN,
268 ParamValidator::PARAM_TYPE =>
'namespace',
271 ParamValidator::PARAM_DEFAULT =>
'all',
272 ParamValidator::PARAM_TYPE => [
278 'filterlanglinks' => [
279 ParamValidator::PARAM_TYPE => [
284 ParamValidator::PARAM_DEFAULT =>
'all'
287 ParamValidator::PARAM_TYPE =>
'integer',
290 ParamValidator::PARAM_TYPE =>
'integer',
293 ParamValidator::PARAM_TYPE => $this->restrictionStore->listAllRestrictionTypes(
true ),
294 ParamValidator::PARAM_ISMULTI => true
297 ParamValidator::PARAM_TYPE =>
299 ParamValidator::PARAM_ISMULTI => true
301 'prfiltercascade' => [
302 ParamValidator::PARAM_DEFAULT =>
'all',
303 ParamValidator::PARAM_TYPE => [
310 ParamValidator::PARAM_TYPE => [
315 ParamValidator::PARAM_DEFAULT =>
'all',
319 ParamValidator::PARAM_DEFAULT => 10,
320 ParamValidator::PARAM_TYPE =>
'limit',
321 IntegerDef::PARAM_MIN => 1,
326 ParamValidator::PARAM_DEFAULT =>
'ascending',
327 ParamValidator::PARAM_TYPE => [
345 'action=query&list=allpages&apfrom=B'
346 =>
'apihelp-query+allpages-example-b',
347 'action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info'
348 =>
'apihelp-query+allpages-example-generator',
349 'action=query&generator=allpages&gaplimit=2&' .
350 'gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content'
351 =>
'apihelp-query+allpages-example-generator-revisions',
357 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allpages';
362class_alias( ApiQueryAllPages::class,
'ApiQueryAllPages' );
Query module to enumerate all available pages.
__construct(ApiQuery $query, string $moduleName, private readonly NamespaceInfo $namespaceInfo, private readonly GenderCache $genderCache, private readonly RestrictionStore $restrictionStore,)
getCacheMode( $params)
Get the cache mode for the data generated by this module.Override this in the module subclass....
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getExamplesMessages()
Returns usage examples for this module.Return value has query strings as keys, with values being eith...
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.1.25, returning boolean false is deprecated...
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()