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' ) {
107 $dir = (
$params[
'dir'] ==
'descending' ?
'older' :
'newer' );
108 $from = (
$params[
'from'] ===
null
116 if ( isset(
$params[
'prefix'] ) ) {
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'] ) ) {
152 $forceNameTitleIndex =
false;
155 if ( isset(
$params[
'maxsize'] ) ) {
157 $forceNameTitleIndex =
false;
163 $this->
addWhere(
'page_id=pr_page' );
165 $db->expr(
'pr_expiry',
'>', $db->timestamp() )->or(
'pr_expiry',
'=',
null )
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' );
215 $dbType = $db->getType();
216 if ( $dbType ===
'mysql' || $dbType ===
'sqlite' ) {
221 $this->
addOption(
'GROUP BY', [
'page_title' ] );
222 } elseif ( $dbType ===
'postgres' && $db->getServerVersion() >= 9.1 ) {
224 $this->
addOption(
'GROUP BY', [
'page_title',
'page_id' ] );
227 $this->
addOption(
'GROUP BY', $selectFields );
230 $forceNameTitleIndex =
false;
233 if ( $forceNameTitleIndex ) {
234 $this->
addOption(
'USE INDEX',
'page_name_title' );
239 $res = $this->
select( __METHOD__ );
242 if ( $this->namespaceInfo->hasGenderDistinction(
$params[
'namespace'] ) ) {
244 foreach ( $res as $row ) {
245 $users[] = $row->page_title;
247 $this->genderCache->doQuery( $users, __METHOD__ );
253 foreach ( $res as $row ) {
254 if ( ++$count > $limit ) {
261 if ( $miserModeFilterRedir && (
int)$row->page_is_redirect !== $miserModeFilterRedirValue ) {
266 if ( $resultPageSet ===
null ) {
267 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
269 'pageid' => (int)$row->page_id,
270 'ns' => $title->getNamespace(),
271 'title' => $title->getPrefixedText()
273 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
279 $resultPageSet->processDbRow( $row );
283 if ( $resultPageSet ===
null ) {
284 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'p' );
297 ParamValidator::PARAM_DEFAULT =>
NS_MAIN,
298 ParamValidator::PARAM_TYPE =>
'namespace',
301 ParamValidator::PARAM_DEFAULT =>
'all',
302 ParamValidator::PARAM_TYPE => [
308 'filterlanglinks' => [
309 ParamValidator::PARAM_TYPE => [
314 ParamValidator::PARAM_DEFAULT =>
'all'
317 ParamValidator::PARAM_TYPE =>
'integer',
320 ParamValidator::PARAM_TYPE =>
'integer',
323 ParamValidator::PARAM_TYPE => $this->restrictionStore->listAllRestrictionTypes(
true ),
324 ParamValidator::PARAM_ISMULTI => true
327 ParamValidator::PARAM_TYPE =>
329 ParamValidator::PARAM_ISMULTI => true
331 'prfiltercascade' => [
332 ParamValidator::PARAM_DEFAULT =>
'all',
333 ParamValidator::PARAM_TYPE => [
340 ParamValidator::PARAM_TYPE => [
345 ParamValidator::PARAM_DEFAULT =>
'all',
349 ParamValidator::PARAM_DEFAULT => 10,
350 ParamValidator::PARAM_TYPE =>
'limit',
351 IntegerDef::PARAM_MIN => 1,
356 ParamValidator::PARAM_DEFAULT =>
'ascending',
357 ParamValidator::PARAM_TYPE => [
373 'action=query&list=allpages&apfrom=B'
374 =>
'apihelp-query+allpages-example-b',
375 'action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info'
376 =>
'apihelp-query+allpages-example-generator',
377 'action=query&generator=allpages&gaplimit=2&' .
378 'gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content'
379 =>
'apihelp-query+allpages-example-generator-revisions',
384 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allpages';
389class_alias( ApiQueryAllPages::class,
'ApiQueryAllPages' );
array $params
The job parameters.
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()