55 parent::__construct( $query, $moduleName,
'ap' );
56 $this->namespaceInfo = $namespaceInfo;
57 $this->genderCache = $genderCache;
58 $this->restrictionStore = $restrictionStore;
74 if ( $resultPageSet->isResolvingRedirects() ) {
75 $this->
dieWithError(
'apierror-allpages-generator-redirects',
'params' );
78 $this->run( $resultPageSet );
85 private function run( $resultPageSet =
null ) {
93 if ( $params[
'continue'] !==
null ) {
95 $op = $params[
'dir'] ==
'descending' ?
'<=' :
'>=';
96 $this->
addWhere( $db->buildComparison( $op, [
'page_title' => $cont[0] ] ) );
99 $miserMode = $this->
getConfig()->get( MainConfigNames::MiserMode );
101 if ( $params[
'filterredir'] ==
'redirects' ) {
103 } elseif ( $params[
'filterredir'] ==
'nonredirects' ) {
108 $this->
addWhereFld(
'page_namespace', $params[
'namespace'] );
109 $dir = ( $params[
'dir'] ==
'descending' ?
'older' :
'newer' );
110 $from = ( $params[
'from'] ===
null
112 : $this->
titlePartToKey( $params[
'from'], $params[
'namespace'] ) );
113 $to = ( $params[
'to'] ===
null
118 if ( isset( $params[
'prefix'] ) ) {
119 $this->
addWhere(
'page_title' . $db->buildLike(
120 $this->titlePartToKey( $params[
'prefix'], $params[
'namespace'] ),
121 $db->anyString() ) );
124 if ( $resultPageSet ===
null ) {
131 $selectFields = $resultPageSet->getPageTableFields();
134 $miserModeFilterRedirValue =
null;
135 $miserModeFilterRedir = $miserMode && $params[
'filterredir'] !==
'all';
136 if ( $miserModeFilterRedir ) {
137 $selectFields[] =
'page_is_redirect';
139 if ( $params[
'filterredir'] ==
'redirects' ) {
140 $miserModeFilterRedirValue = 1;
141 } elseif ( $params[
'filterredir'] ==
'nonredirects' ) {
142 $miserModeFilterRedirValue = 0;
147 $forceNameTitleIndex =
true;
148 if ( isset( $params[
'minsize'] ) ) {
149 $this->
addWhere(
'page_len>=' . (
int)$params[
'minsize'] );
150 $forceNameTitleIndex =
false;
153 if ( isset( $params[
'maxsize'] ) ) {
154 $this->
addWhere(
'page_len<=' . (
int)$params[
'maxsize'] );
155 $forceNameTitleIndex =
false;
159 if ( $params[
'prtype'] || $params[
'prexpiry'] !=
'all' ) {
161 $this->
addWhere(
'page_id=pr_page' );
162 $this->
addWhere(
"pr_expiry > {$db->addQuotes( $db->timestamp() )} OR pr_expiry IS NULL" );
164 if ( $params[
'prtype'] ) {
165 $this->
addWhereFld(
'pr_type', $params[
'prtype'] );
167 if ( isset( $params[
'prlevel'] ) ) {
169 $prlevel = array_diff( $params[
'prlevel'], [
'',
'*' ] );
171 if ( count( $prlevel ) ) {
175 if ( $params[
'prfiltercascade'] ==
'cascading' ) {
177 } elseif ( $params[
'prfiltercascade'] ==
'noncascading' ) {
181 $forceNameTitleIndex =
false;
183 if ( $params[
'prexpiry'] ==
'indefinite' ) {
184 $this->
addWhereFld(
'pr_expiry', [ $db->getInfinity(),
null ] );
185 } elseif ( $params[
'prexpiry'] ==
'definite' ) {
186 $this->
addWhere(
"pr_expiry != {$db->addQuotes( $db->getInfinity() )}" );
190 } elseif ( isset( $params[
'prlevel'] ) ) {
192 [
'apierror-invalidparammix-mustusewith',
'prlevel',
'prtype' ],
'invalidparammix'
196 if ( $params[
'filterlanglinks'] ==
'withoutlanglinks' ) {
198 $this->
addJoinConds( [
'langlinks' => [
'LEFT JOIN',
'page_id=ll_from' ] ] );
199 $this->
addWhere( [
'll_from' =>
null ] );
200 $forceNameTitleIndex =
false;
201 } elseif ( $params[
'filterlanglinks'] ==
'withlanglinks' ) {
203 $this->
addWhere(
'page_id=ll_from' );
211 $dbType = $db->getType();
212 if ( $dbType ===
'mysql' || $dbType ===
'sqlite' ) {
217 $this->
addOption(
'GROUP BY', [
'page_title' ] );
218 } elseif ( $dbType ===
'postgres' && $db->getServerVersion() >= 9.1 ) {
220 $this->
addOption(
'GROUP BY', [
'page_title',
'page_id' ] );
223 $this->
addOption(
'GROUP BY', $selectFields );
226 $forceNameTitleIndex =
false;
229 if ( $forceNameTitleIndex ) {
230 $this->
addOption(
'USE INDEX',
'page_name_title' );
233 $limit = $params[
'limit'];
235 $res = $this->
select( __METHOD__ );
238 if ( $this->namespaceInfo->hasGenderDistinction( $params[
'namespace'] ) ) {
240 foreach ( $res as $row ) {
241 $users[] = $row->page_title;
243 $this->genderCache->doQuery( $users, __METHOD__ );
249 foreach ( $res as $row ) {
250 if ( ++$count > $limit ) {
257 if ( $miserModeFilterRedir && (
int)$row->page_is_redirect !== $miserModeFilterRedirValue ) {
262 if ( $resultPageSet ===
null ) {
263 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
265 'pageid' => (int)$row->page_id,
266 'ns' => $title->getNamespace(),
267 'title' => $title->getPrefixedText()
269 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
275 $resultPageSet->processDbRow( $row );
279 if ( $resultPageSet ===
null ) {
280 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'p' );
293 ParamValidator::PARAM_DEFAULT =>
NS_MAIN,
294 ParamValidator::PARAM_TYPE =>
'namespace',
297 ParamValidator::PARAM_DEFAULT =>
'all',
298 ParamValidator::PARAM_TYPE => [
305 ParamValidator::PARAM_TYPE =>
'integer',
308 ParamValidator::PARAM_TYPE =>
'integer',
311 ParamValidator::PARAM_TYPE => $this->restrictionStore->listAllRestrictionTypes(
true ),
312 ParamValidator::PARAM_ISMULTI =>
true
315 ParamValidator::PARAM_TYPE =>
316 $this->
getConfig()->get( MainConfigNames::RestrictionLevels ),
317 ParamValidator::PARAM_ISMULTI =>
true
319 'prfiltercascade' => [
320 ParamValidator::PARAM_DEFAULT =>
'all',
321 ParamValidator::PARAM_TYPE => [
328 ParamValidator::PARAM_DEFAULT => 10,
329 ParamValidator::PARAM_TYPE =>
'limit',
330 IntegerDef::PARAM_MIN => 1,
335 ParamValidator::PARAM_DEFAULT =>
'ascending',
336 ParamValidator::PARAM_TYPE => [
341 'filterlanglinks' => [
342 ParamValidator::PARAM_TYPE => [
347 ParamValidator::PARAM_DEFAULT =>
'all'
350 ParamValidator::PARAM_TYPE => [
355 ParamValidator::PARAM_DEFAULT =>
'all',
360 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
369 'action=query&list=allpages&apfrom=B'
370 =>
'apihelp-query+allpages-example-b',
371 'action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info'
372 =>
'apihelp-query+allpages-example-generator',
373 'action=query&generator=allpages&gaplimit=2&' .
374 'gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content'
375 =>
'apihelp-query+allpages-example-generator-revisions',
380 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allpages';
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
const LIMIT_BIG1
Fast query, standard limit.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
Query module to enumerate all available pages.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getCacheMode( $params)
Get the cache mode for the data generated by this module.
executeGenerator( $resultPageSet)
getHelpUrls()
Return links to more detailed help pages about the module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getExamplesMessages()
Returns usage examples for this module.
__construct(ApiQuery $query, $moduleName, NamespaceInfo $namespaceInfo, GenderCache $genderCache, RestrictionStore $restrictionStore)
addWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
addFields( $value)
Add a set of fields to select to the internal array.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
getDB()
Get the Query database connection (read-only)
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere( [ $field => $value ] )
titlePartToKey( $titlePart, $namespace=NS_MAIN)
Convert an input title or title prefix into a dbkey.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
This is the main query class.
Caches user genders when needed to use correct namespace aliases.
A class containing constants representing the names of configuration variables.