32 parent::__construct(
$query, $moduleName,
'ac' );
44 $this->
run( $resultPageSet );
50 private function run( $resultPageSet =
null ) {
57 if ( !is_null(
$params[
'continue'] ) ) {
58 $cont = explode(
'|',
$params[
'continue'] );
60 $op =
$params[
'dir'] ==
'descending' ?
'<' :
'>';
61 $cont_from = $db->addQuotes( $cont[0] );
62 $this->
addWhere(
"cat_title $op= $cont_from" );
65 $dir = (
$params[
'dir'] ==
'descending' ?
'older' :
'newer' );
66 $from = (
$params[
'from'] ===
null
76 if ( $dir ==
'newer' ) {
82 if ( isset(
$params[
'prefix'] ) ) {
83 $this->
addWhere(
'cat_title' . $db->buildLike(
89 $sort = (
$params[
'dir'] ==
'descending' ?
' DESC' :
'' );
92 $prop = array_flip(
$params[
'prop'] );
93 $this->
addFieldsIf( [
'cat_pages',
'cat_subcats',
'cat_files' ], isset( $prop[
'size'] ) );
94 if ( isset( $prop[
'hidden'] ) ) {
95 $this->
addTables( [
'page',
'page_props' ] );
97 'page' => [
'LEFT JOIN', [
99 'page_title=cat_title' ] ],
100 'page_props' => [
'LEFT JOIN', [
102 'pp_propname' =>
'hiddencat' ] ],
104 $this->
addFields( [
'cat_hidden' =>
'pp_propname' ] );
113 foreach (
$res as $row ) {
114 if ( ++$count >
$params[
'limit'] ) {
122 $titleObj = Title::makeTitle(
NS_CATEGORY, $row->cat_title );
123 if ( !is_null( $resultPageSet ) ) {
124 $pages[] = $titleObj;
128 if ( isset( $prop[
'size'] ) ) {
129 $item[
'size'] = intval( $row->cat_pages );
130 $item[
'pages'] = $row->cat_pages - $row->cat_subcats - $row->cat_files;
131 $item[
'files'] = intval( $row->cat_files );
132 $item[
'subcats'] = intval( $row->cat_subcats );
134 if ( isset( $prop[
'hidden'] ) ) {
135 $item[
'hidden'] = (bool)$row->cat_hidden;
137 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $item );
145 if ( is_null( $resultPageSet ) ) {
146 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'c' );
148 $resultPageSet->populateFromTitles( $pages );
191 'action=query&list=allcategories&acprop=size'
192 =>
'apihelp-query+allcategories-example-size',
193 'action=query&generator=allcategories&gacprefix=List&prop=info'
194 =>
'apihelp-query+allcategories-example-generator',
199 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allcategories';
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'.
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_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
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 categories, even the ones that don't have category pages.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
__construct(ApiQuery $query, $moduleName)
executeGenerator( $resultPageSet)
Execute this module as a generator.
getExamplesMessages()
Returns usage examples for this module.
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.
getHelpUrls()
Return links to more detailed help pages about the module.
run( $resultPageSet=null)
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)
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
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.
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
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
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