58 parent::__construct( $query, $moduleName,
'ap' );
59 $this->namespaceInfo = $namespaceInfo;
60 $this->genderCache = $genderCache;
61 $this->restrictionStore = $restrictionStore;
77 if ( $resultPageSet->isResolvingRedirects() ) {
78 $this->
dieWithError(
'apierror-allpages-generator-redirects',
'params' );
81 $this->
run( $resultPageSet );
88 private function run( $resultPageSet =
null ) {
96 if (
$params[
'continue'] !==
null ) {
98 $op =
$params[
'dir'] ==
'descending' ?
'<=' :
'>=';
99 $this->
addWhere( $db->expr(
'page_title', $op, $cont[0] ) );
102 $miserMode = $this->
getConfig()->get( MainConfigNames::MiserMode );
104 if (
$params[
'filterredir'] ==
'redirects' ) {
106 } elseif (
$params[
'filterredir'] ==
'nonredirects' ) {
112 $dir = (
$params[
'dir'] ==
'descending' ?
'older' :
'newer' );
113 $from = (
$params[
'from'] ===
null
121 if ( isset(
$params[
'prefix'] ) ) {
131 if ( $resultPageSet ===
null ) {
138 $selectFields = $resultPageSet->getPageTableFields();
141 $miserModeFilterRedirValue =
null;
142 $miserModeFilterRedir = $miserMode &&
$params[
'filterredir'] !==
'all';
143 if ( $miserModeFilterRedir ) {
144 $selectFields[] =
'page_is_redirect';
146 if (
$params[
'filterredir'] ==
'redirects' ) {
147 $miserModeFilterRedirValue = 1;
148 } elseif (
$params[
'filterredir'] ==
'nonredirects' ) {
149 $miserModeFilterRedirValue = 0;
154 $forceNameTitleIndex =
true;
155 if ( isset(
$params[
'minsize'] ) ) {
157 $forceNameTitleIndex =
false;
160 if ( isset(
$params[
'maxsize'] ) ) {
162 $forceNameTitleIndex =
false;
168 $this->
addWhere(
'page_id=pr_page' );
170 $db->expr(
'pr_expiry',
'>', $db->timestamp() )->or(
'pr_expiry',
'=',
null )
176 if ( isset(
$params[
'prlevel'] ) ) {
178 $prlevel = array_diff(
$params[
'prlevel'], [
'',
'*' ] );
180 if ( count( $prlevel ) ) {
184 if (
$params[
'prfiltercascade'] ==
'cascading' ) {
186 } elseif (
$params[
'prfiltercascade'] ==
'noncascading' ) {
190 $forceNameTitleIndex =
false;
192 if (
$params[
'prexpiry'] ==
'indefinite' ) {
193 $this->
addWhereFld(
'pr_expiry', [ $db->getInfinity(),
null ] );
194 } elseif (
$params[
'prexpiry'] ==
'definite' ) {
195 $this->
addWhere( $db->expr(
'pr_expiry',
'!=', $db->getInfinity() ) );
199 } elseif ( isset(
$params[
'prlevel'] ) ) {
201 [
'apierror-invalidparammix-mustusewith',
'prlevel',
'prtype' ],
'invalidparammix'
205 if (
$params[
'filterlanglinks'] ==
'withoutlanglinks' ) {
207 $this->
addJoinConds( [
'langlinks' => [
'LEFT JOIN',
'page_id=ll_from' ] ] );
208 $this->
addWhere( [
'll_from' =>
null ] );
209 $forceNameTitleIndex =
false;
210 } elseif (
$params[
'filterlanglinks'] ==
'withlanglinks' ) {
212 $this->
addWhere(
'page_id=ll_from' );
220 $dbType = $db->getType();
221 if ( $dbType ===
'mysql' || $dbType ===
'sqlite' ) {
226 $this->
addOption(
'GROUP BY', [
'page_title' ] );
227 } elseif ( $dbType ===
'postgres' && $db->getServerVersion() >= 9.1 ) {
229 $this->
addOption(
'GROUP BY', [
'page_title',
'page_id' ] );
232 $this->
addOption(
'GROUP BY', $selectFields );
235 $forceNameTitleIndex =
false;
238 if ( $forceNameTitleIndex ) {
239 $this->
addOption(
'USE INDEX',
'page_name_title' );
244 $res = $this->
select( __METHOD__ );
247 if ( $this->namespaceInfo->hasGenderDistinction(
$params[
'namespace'] ) ) {
249 foreach ( $res as $row ) {
250 $users[] = $row->page_title;
252 $this->genderCache->doQuery( $users, __METHOD__ );
258 foreach ( $res as $row ) {
259 if ( ++$count > $limit ) {
266 if ( $miserModeFilterRedir && (
int)$row->page_is_redirect !== $miserModeFilterRedirValue ) {
271 if ( $resultPageSet ===
null ) {
272 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
274 'pageid' => (int)$row->page_id,
275 'ns' => $title->getNamespace(),
276 'title' => $title->getPrefixedText()
278 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
284 $resultPageSet->processDbRow( $row );
288 if ( $resultPageSet ===
null ) {
289 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'p' );
302 ParamValidator::PARAM_DEFAULT =>
NS_MAIN,
303 ParamValidator::PARAM_TYPE =>
'namespace',
306 ParamValidator::PARAM_DEFAULT =>
'all',
307 ParamValidator::PARAM_TYPE => [
313 'filterlanglinks' => [
314 ParamValidator::PARAM_TYPE => [
319 ParamValidator::PARAM_DEFAULT =>
'all'
322 ParamValidator::PARAM_TYPE =>
'integer',
325 ParamValidator::PARAM_TYPE =>
'integer',
328 ParamValidator::PARAM_TYPE => $this->restrictionStore->listAllRestrictionTypes(
true ),
329 ParamValidator::PARAM_ISMULTI => true
332 ParamValidator::PARAM_TYPE =>
333 $this->
getConfig()->get( MainConfigNames::RestrictionLevels ),
334 ParamValidator::PARAM_ISMULTI => true
336 'prfiltercascade' => [
337 ParamValidator::PARAM_DEFAULT =>
'all',
338 ParamValidator::PARAM_TYPE => [
345 ParamValidator::PARAM_TYPE => [
350 ParamValidator::PARAM_DEFAULT =>
'all',
354 ParamValidator::PARAM_DEFAULT => 10,
355 ParamValidator::PARAM_TYPE =>
'limit',
356 IntegerDef::PARAM_MIN => 1,
361 ParamValidator::PARAM_DEFAULT =>
'ascending',
362 ParamValidator::PARAM_TYPE => [
369 if ( $this->
getConfig()->
get( MainConfigNames::MiserMode ) ) {
378 'action=query&list=allpages&apfrom=B'
379 =>
'apihelp-query+allpages-example-b',
380 'action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info'
381 =>
'apihelp-query+allpages-example-generator',
382 'action=query&generator=allpages&gaplimit=2&' .
383 'gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content'
384 =>
'apihelp-query+allpages-example-generator-revisions',
389 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allpages';
array $params
The job parameters.
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.
A class containing constants representing the names of configuration variables.