r32214 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32213‎ | r32214 | r32215 >
Date:09:20, 20 March 2008
Author:vasilievvv
Status:old
Tags:
Comment:
* (bug 13395) list=allcategories should use category table
* cat_hidden doesn't work. why?
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllCategories.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryAllCategories.php
@@ -53,21 +53,27 @@
5454 $db = $this->getDB();
5555 $params = $this->extractRequestParams();
5656
57 - $this->addTables('categorylinks');
58 - $this->addFields('cl_to');
 57+ $this->addTables('category');
 58+ $this->addFields('cat_title');
5959
6060 if (!is_null($params['from']))
61 - $this->addWhere('cl_to>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from'])));
 61+ $this->addWhere('cat_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from'])));
6262 if (isset ($params['prefix']))
63 - $this->addWhere("cl_to LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'");
 63+ $this->addWhere("cat_title LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'");
6464
6565 $this->addOption('LIMIT', $params['limit']+1);
66 - $this->addOption('ORDER BY', 'cl_to' . ($params['dir'] == 'descending' ? ' DESC' : ''));
 66+ $this->addOption('ORDER BY', 'cat_title' . ($params['dir'] == 'descending' ? ' DESC' : ''));
6767 $this->addOption('DISTINCT');
 68+
 69+ $prop = array_flip($params['prop']);
 70+ $this->addFieldsIf( array( 'cat_pages', 'cat_subcats', 'cat_files' ), isset($prop['size']) );
 71+ //$this->addFieldsIf( 'cat_hidden', isset($prop['hidden']) );
6872
6973 $res = $this->select(__METHOD__);
7074
7175 $pages = array();
 76+ $categories = array();
 77+ $result = $this->getResult();
7278 $count = 0;
7379 while ($row = $db->fetchObject($res)) {
7480 if (++ $count > $params['limit']) {
@@ -78,19 +84,29 @@
7985 }
8086
8187 // Normalize titles
82 - $titleObj = Title::makeTitle(NS_CATEGORY, $row->cl_to);
 88+ $titleObj = Title::makeTitle(NS_CATEGORY, $row->cat_title);
8389 if(!is_null($resultPageSet))
8490 $pages[] = $titleObj->getPrefixedText();
85 - else
86 - // Don't show "Category:" everywhere in non-generator mode
87 - $pages[] = $titleObj->getText();
 91+ else {
 92+ $item = array();
 93+ $result->setContent( $item, $titleObj->getText() );
 94+ if( isset( $prop['size'] ) ) {
 95+ $item['size'] = $row->cat_pages;
 96+ $item['pages'] = $row->cat_pages - $row->cat_subcats - $row->cat_files;
 97+ $item['files'] = $row->cat_files;
 98+ $item['subcats'] = $row->cat_subcats;
 99+ }
 100+ //Isn't populated, so doesn't work
 101+ //if( isset( $prop['hidden'] ) && $row->cat_hidden )
 102+ // $item['hidden'] = '';
 103+ $categories[] = $item;
 104+ }
88105 }
89106 $db->freeResult($res);
90107
91108 if (is_null($resultPageSet)) {
92 - $result = $this->getResult();
93 - $result->setIndexedTagName($pages, 'c');
94 - $result->addValue('query', $this->getModuleName(), $pages);
 109+ $result->setIndexedTagName($categories, 'c');
 110+ $result->addValue('query', $this->getModuleName(), $categories);
95111 } else {
96112 $resultPageSet->populateFromTitles($pages);
97113 }
@@ -113,7 +129,12 @@
114130 ApiBase :: PARAM_MIN => 1,
115131 ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
116132 ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
117 - )
 133+ ),
 134+ 'prop' => array (
 135+ ApiBase :: PARAM_TYPE => array( 'size', /*'hidden'*/ ),
 136+ ApiBase :: PARAM_DFLT => '',
 137+ ApiBase :: PARAM_ISMULTI => true
 138+ ),
118139 );
119140 }
120141
@@ -122,7 +143,8 @@
123144 'from' => 'The category to start enumerating from.',
124145 'prefix' => 'Search for all category titles that begin with this value.',
125146 'dir' => 'Direction to sort in.',
126 - 'limit' => 'How many categories to return.'
 147+ 'limit' => 'How many categories to return.',
 148+ 'prop' => 'Indicates if API should output category size',
127149 );
128150 }
129151
@@ -132,6 +154,7 @@
133155
134156 protected function getExamples() {
135157 return array (
 158+ 'api.php?action=query&list=allcategories&acprop=size',
136159 'api.php?action=query&generator=allcategories&gacprefix=List&prop=info',
137160 );
138161 }
Index: trunk/phase3/RELEASE-NOTES
@@ -110,6 +110,8 @@
111111 * (bug 13428) Fix regression in protection form layout HTML validity
112112 * (bug 9403) Sanitize newlines from search term input
113113 * (bug 13429) Separate date and time in message sp-newimages-showfrom
 114+* (bug 13137) Allow setting 'editprotected' right separately from 'protect',
 115+ so groups may optionally edit protected pages without having 'protect' perms
114116
115117
116118 === API changes in 1.13 ===
@@ -133,8 +135,7 @@
134136 * (bug 13390) One invalid title no longer kills an entire API query
135137 * (bug 13419) Fix gblredirect so it actually works
136138 * (bug 13418) Disable eiredirect because it's useless
137 -* (bug 13137) Allow setting 'editprotected' right separately from 'protect',
138 - so groups may optionally edit protected pages without having 'protect' perms
 139+* (bug 13395) list=allcategories should use category table
139140
140141 === Languages updated in 1.13 ===
141142

Status & tagging log