39 parent::__construct( $query, $moduleName,
'ap' );
40 $this->namespaceInfo = $namespaceInfo;
41 $this->genderCache = $genderCache;
42 $this->restrictionStore = $restrictionStore;
59 if ( $resultPageSet->isResolvingRedirects() ) {
60 $this->
dieWithError(
'apierror-allpages-generator-redirects',
'params' );
63 $this->run( $resultPageSet );
70 private function run( $resultPageSet =
null ) {
78 if ( $params[
'continue'] !==
null ) {
80 $op = $params[
'dir'] ==
'descending' ?
'<=' :
'>=';
81 $this->
addWhere( $db->expr(
'page_title', $op, $cont[0] ) );
86 if ( $params[
'filterredir'] ==
'redirects' ) {
88 } elseif ( $params[
'filterredir'] ==
'nonredirects' ) {
93 $this->
addWhereFld(
'page_namespace', $params[
'namespace'] );
94 $dir = (
$params[
'dir'] ==
'descending' ?
'older' :
'newer' );
95 $from = (
$params[
'from'] ===
null
97 : $this->
titlePartToKey( $params[
'from'], $params[
'namespace'] ) );
103 if ( isset( $params[
'prefix'] ) ) {
108 new LikeValue( $this->
titlePartToKey( $params[
'prefix'], $params[
'namespace'] ), $db->anyString() )
113 if ( $resultPageSet ===
null ) {
120 $selectFields = $resultPageSet->getPageTableFields();
123 $miserModeFilterRedirValue =
null;
124 $miserModeFilterRedir = $miserMode &&
$params[
'filterredir'] !==
'all';
125 if ( $miserModeFilterRedir ) {
126 $selectFields[] =
'page_is_redirect';
128 if ( $params[
'filterredir'] ==
'redirects' ) {
129 $miserModeFilterRedirValue = 1;
130 } elseif ( $params[
'filterredir'] ==
'nonredirects' ) {
131 $miserModeFilterRedirValue = 0;
136 $forceNameTitleIndex =
true;
137 if ( isset( $params[
'minsize'] ) ) {
138 $this->
addWhere(
'page_len>=' . (
int)$params[
'minsize'] );
139 $forceNameTitleIndex =
false;
142 if ( !$miserMode && isset( $params[
'maxsize'] ) ) {
143 $this->
addWhere(
'page_len<=' . (
int)$params[
'maxsize'] );
144 $forceNameTitleIndex =
false;
148 if ( $params[
'prtype'] || $params[
'prexpiry'] !=
'all' ) {
150 $this->
addWhere(
'page_id=pr_page' );
152 $db->expr(
'pr_expiry',
'>', $db->timestamp() )->or(
'pr_expiry',
'=',
null )
155 if ( $params[
'prtype'] ) {
156 $this->
addWhereFld(
'pr_type', $params[
'prtype'] );
158 if ( isset( $params[
'prlevel'] ) ) {
160 $prlevel = array_diff( $params[
'prlevel'], [
'',
'*' ] );
162 if ( count( $prlevel ) ) {
166 if ( $params[
'prfiltercascade'] ==
'cascading' ) {
168 } elseif ( $params[
'prfiltercascade'] ==
'noncascading' ) {
172 $forceNameTitleIndex =
false;
174 if ( $params[
'prexpiry'] ==
'indefinite' ) {
175 $this->
addWhereFld(
'pr_expiry', [ $db->getInfinity(),
null ] );
176 } elseif ( $params[
'prexpiry'] ==
'definite' ) {
177 $this->
addWhere( $db->expr(
'pr_expiry',
'!=', $db->getInfinity() ) );
181 } elseif ( isset( $params[
'prlevel'] ) ) {
183 [
'apierror-invalidparammix-mustusewith',
'prlevel',
'prtype' ],
'invalidparammix'
187 if ( $params[
'filterlanglinks'] ==
'withoutlanglinks' ) {
189 $this->
addJoinConds( [
'langlinks' => [
'LEFT JOIN',
'page_id=ll_from' ] ] );
190 $this->
addWhere( [
'll_from' =>
null ] );
191 $forceNameTitleIndex =
false;
192 } elseif ( $params[
'filterlanglinks'] ==
'withlanglinks' ) {
194 $this->
addWhere(
'page_id=ll_from' );
197 $dbType = $db->getType();
198 if ( $dbType ===
'mysql' || $dbType ===
'sqlite' ) {
200 $this->
addOption(
'GROUP BY', [
'page_title' ] );
203 $this->
addOption(
'GROUP BY', [
'page_title',
'page_id' ] );
206 $forceNameTitleIndex =
false;
209 if ( $forceNameTitleIndex ) {
210 $this->
addOption(
'USE INDEX',
'page_name_title' );
215 $res = $this->
select( __METHOD__ );
218 if ( $this->namespaceInfo->hasGenderDistinction( $params[
'namespace'] ) ) {
220 foreach ( $res as $row ) {
221 $users[] = $row->page_title;
223 $this->genderCache->doQuery( $users, __METHOD__ );
229 foreach ( $res as $row ) {
230 if ( ++$count > $limit ) {
237 if ( $miserModeFilterRedir && (
int)$row->page_is_redirect !== $miserModeFilterRedirValue ) {
242 if ( $resultPageSet ===
null ) {
245 'pageid' => (int)$row->page_id,
246 'ns' => $title->getNamespace(),
247 'title' => $title->getPrefixedText()
249 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
255 $resultPageSet->processDbRow( $row );
259 if ( $resultPageSet ===
null ) {
260 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'p' );
274 ParamValidator::PARAM_DEFAULT =>
NS_MAIN,
275 ParamValidator::PARAM_TYPE =>
'namespace',
278 ParamValidator::PARAM_DEFAULT =>
'all',
279 ParamValidator::PARAM_TYPE => [
285 'filterlanglinks' => [
286 ParamValidator::PARAM_TYPE => [
291 ParamValidator::PARAM_DEFAULT =>
'all'
294 ParamValidator::PARAM_TYPE =>
'integer',
297 ParamValidator::PARAM_TYPE =>
'integer',
300 ParamValidator::PARAM_TYPE => $this->restrictionStore->listAllRestrictionTypes(
true ),
301 ParamValidator::PARAM_ISMULTI => true
304 ParamValidator::PARAM_TYPE =>
306 ParamValidator::PARAM_ISMULTI => true
308 'prfiltercascade' => [
309 ParamValidator::PARAM_DEFAULT =>
'all',
310 ParamValidator::PARAM_TYPE => [
317 ParamValidator::PARAM_TYPE => [
322 ParamValidator::PARAM_DEFAULT =>
'all',
326 ParamValidator::PARAM_DEFAULT => 10,
327 ParamValidator::PARAM_TYPE =>
'limit',
328 IntegerDef::PARAM_MIN => 1,
333 ParamValidator::PARAM_DEFAULT =>
'ascending',
334 ParamValidator::PARAM_TYPE => [
352 'action=query&list=allpages&apfrom=B'
353 =>
'apihelp-query+allpages-example-b',
354 'action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info'
355 =>
'apihelp-query+allpages-example-generator',
356 'action=query&generator=allpages&gaplimit=2&' .
357 'gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content'
358 =>
'apihelp-query+allpages-example-generator-revisions',
364 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allpages';
369class_alias( ApiQueryAllPages::class,
'ApiQueryAllPages' );
Query module to enumerate all available pages.
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...
__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()