32 parent::__construct(
$query, $moduleName,
'ap' );
48 if ( $resultPageSet->isResolvingRedirects() ) {
49 $this->
dieWithError(
'apierror-allpages-generator-redirects',
'params' );
52 $this->
run( $resultPageSet );
59 private function run( $resultPageSet =
null ) {
68 $cont = explode(
'|',
$params[
'continue'] );
70 $op =
$params[
'dir'] ==
'descending' ?
'<' :
'>';
71 $cont_from = $db->addQuotes( $cont[0] );
72 $this->
addWhere(
"page_title $op= $cont_from" );
75 $miserMode = $this->
getConfig()->get(
'MiserMode' );
77 if (
$params[
'filterredir'] ==
'redirects' ) {
85 $dir = (
$params[
'dir'] ==
'descending' ?
'older' :
'newer' );
86 $from = (
$params[
'from'] ===
null
95 $this->
addWhere(
'page_title' . $db->buildLike(
100 if (
is_null( $resultPageSet ) ) {
107 $selectFields = $resultPageSet->getPageTableFields();
110 $miserModeFilterRedirValue =
null;
111 $miserModeFilterRedir = $miserMode &&
$params[
'filterredir'] !==
'all';
112 if ( $miserModeFilterRedir ) {
113 $selectFields[] =
'page_is_redirect';
115 if (
$params[
'filterredir'] ==
'redirects' ) {
116 $miserModeFilterRedirValue = 1;
118 $miserModeFilterRedirValue = 0;
123 $forceNameTitleIndex =
true;
126 $forceNameTitleIndex =
false;
131 $forceNameTitleIndex =
false;
137 $this->
addWhere(
'page_id=pr_page' );
138 $this->
addWhere(
"pr_expiry > {$db->addQuotes( $db->timestamp() )} OR pr_expiry IS NULL" );
147 if ( count( $prlevel ) ) {
151 if (
$params[
'prfiltercascade'] ==
'cascading' ) {
157 $forceNameTitleIndex =
false;
159 if (
$params[
'prexpiry'] ==
'indefinite' ) {
160 $this->
addWhere(
"pr_expiry = {$db->addQuotes( $db->getInfinity() )} OR pr_expiry IS NULL" );
162 $this->
addWhere(
"pr_expiry != {$db->addQuotes( $db->getInfinity() )}" );
168 [
'apierror-invalidparammix-mustusewith',
'prlevel',
'prtype' ],
'invalidparammix'
172 if (
$params[
'filterlanglinks'] ==
'withoutlanglinks' ) {
174 $this->
addJoinConds( [
'langlinks' => [
'LEFT JOIN',
'page_id=ll_from' ] ] );
175 $this->
addWhere(
'll_from IS NULL' );
176 $forceNameTitleIndex =
false;
179 $this->
addWhere(
'page_id=ll_from' );
187 $dbType = $db->getType();
188 if ( $dbType ===
'mysql' || $dbType ===
'sqlite' ) {
193 $this->
addOption(
'GROUP BY', [
'page_title' ] );
194 }
elseif ( $dbType ===
'postgres' && $db->getServerVersion() >= 9.1 ) {
196 $this->
addOption(
'GROUP BY', [
'page_title',
'page_id' ] );
199 $this->
addOption(
'GROUP BY', $selectFields );
202 $forceNameTitleIndex =
false;
205 if ( $forceNameTitleIndex ) {
206 $this->
addOption(
'USE INDEX',
'name_title' );
214 if ( MWNamespace::hasGenderDistinction(
$params[
'namespace'] ) ) {
216 foreach (
$res as $row ) {
217 $users[] = $row->page_title;
219 MediaWikiServices::getInstance()->getGenderCache()->doQuery( $users, __METHOD__ );
225 foreach (
$res as $row ) {
226 if ( ++$count > $limit ) {
233 if ( $miserModeFilterRedir && (
int)$row->page_is_redirect !== $miserModeFilterRedirValue ) {
238 if (
is_null( $resultPageSet ) ) {
239 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
241 'pageid' => (
int)$row->page_id,
242 'ns' => (
int)$title->getNamespace(),
243 'title' => $title->getPrefixedText()
251 $resultPageSet->processDbRow( $row );
255 if (
is_null( $resultPageSet ) ) {
256 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'p' );
274 ApiBase::PARAM_TYPE => [
294 'prfiltercascade' => [
296 ApiBase::PARAM_TYPE => [
316 'filterlanglinks' => [
334 if ( $this->
getConfig()->
get(
'MiserMode' ) ) {
343 'action=query&list=allpages&apfrom=B'
344 =>
'apihelp-query+allpages-example-B',
345 'action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info'
346 =>
'apihelp-query+allpages-example-generator',
347 'action=query&generator=allpages&gaplimit=2&' .
348 'gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content'
349 =>
'apihelp-query+allpages-example-generator-revisions',
354 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allpages';
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Program or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these that in whole or in part contains or is derived from the Program or any part to be licensed as a whole at no charge to all third parties under the terms of this License c If the modified program normally reads commands interactively when run
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
const PARAM_HELP_MSG_APPEND
((string|array|Message)[]) Specify additional i18n messages to append to the normal message for this ...
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
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.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
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)
run( $resultPageSet=null)
__construct(ApiQuery $query, $moduleName)
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.
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)
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
addWhereFld( $field, $value)
Equivalent to addWhere(array($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.
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like select() and insert() are usually more convenient. They take care of things like table prefixes and escaping for you. If you really need to make your own SQL
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query