r50181 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50180‎ | r50181 | r50182 >
Date:15:10, 4 May 2009
Author:catrope
Status:ok
Tags:
Comment:
API: (bug 18518) Add clprop=hidden to prop=categories. Also use array_flip($params['prop']) to simplify code
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryCategories.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryCategories.php
@@ -53,7 +53,7 @@
5454 return; // nothing to do
5555
5656 $params = $this->extractRequestParams();
57 - $prop = $params['prop'];
 57+ $prop = array_flip((array)$params['prop']);
5858 $show = array_flip((array)$params['show']);
5959
6060 $this->addFields(array (
@@ -61,23 +61,8 @@
6262 'cl_to'
6363 ));
6464
65 - $fld_sortkey = $fld_timestamp = false;
66 - if (!is_null($prop)) {
67 - foreach($prop as $p) {
68 - switch ($p) {
69 - case 'sortkey':
70 - $this->addFields('cl_sortkey');
71 - $fld_sortkey = true;
72 - break;
73 - case 'timestamp':
74 - $this->addFields('cl_timestamp');
75 - $fld_timestamp = true;
76 - break;
77 - default :
78 - ApiBase :: dieDebug(__METHOD__, "Unknown prop=$p");
79 - }
80 - }
81 - }
 65+ $this->addFieldsIf('cl_sortkey', isset($prop['sortkey']));
 66+ $this->addFieldsIf('cl_timestamp', isset($prop['timestamp']));
8267
8368 $this->addTables('categorylinks');
8469 $this->addWhereFld('cl_from', array_keys($this->getPageSet()->getGoodTitles()));
@@ -107,10 +92,11 @@
10893 }
10994 if(isset($show['hidden']) && isset($show['!hidden']))
11095 $this->dieUsage("Incorrect parameter - mutually exclusive values may not be supplied", 'show');
111 - if(isset($show['hidden']) || isset($show['!hidden']))
 96+ if(isset($show['hidden']) || isset($show['!hidden']) || isset($prop['hidden']))
11297 {
11398 $this->addOption('STRAIGHT_JOIN');
11499 $this->addTables(array('page', 'page_props'));
 100+ $this->addFieldsIf('pp_propname', isset($prop['hidden']));
115101 $this->addJoinConds(array(
116102 'page' => array('LEFT JOIN', array(
117103 'page_namespace' => NS_CATEGORY,
@@ -121,7 +107,7 @@
122108 ));
123109 if(isset($show['hidden']))
124110 $this->addWhere(array('pp_propname IS NOT NULL'));
125 - else
 111+ else if(isset($show['!hidden']))
126112 $this->addWhere(array('pp_propname IS NULL'));
127113 }
128114
@@ -150,10 +136,12 @@
151137 $title = Title :: makeTitle(NS_CATEGORY, $row->cl_to);
152138 $vals = array();
153139 ApiQueryBase :: addTitleInfo($vals, $title);
154 - if ($fld_sortkey)
 140+ if (isset($prop['sortkey']))
155141 $vals['sortkey'] = $row->cl_sortkey;
156 - if ($fld_timestamp)
 142+ if (isset($prop['timestamp']))
157143 $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->cl_timestamp);
 144+ if (isset($prop['hidden']) && !is_null($row->pp_propname))
 145+ $vals['hidden'] = '';
158146
159147 $fit = $this->addPageSubItem($row->cl_from, $vals);
160148 if(!$fit)
@@ -190,6 +178,7 @@
191179 ApiBase :: PARAM_TYPE => array (
192180 'sortkey',
193181 'timestamp',
 182+ 'hidden',
194183 )
195184 ),
196185 'show' => array(
Index: trunk/phase3/RELEASE-NOTES
@@ -133,6 +133,7 @@
134134 * (bug 18617) Add xml:space="preserve" attribute to relevant tags in XML output
135135 * Added PHP and database version to meta=siteinfo output
136136 * (bug 18533) Add readonly message to meta=siteinfo output
 137+* (bug 18518) Add clprop=hidden to prop=categories
137138
138139 === Languages updated in 1.16 ===
139140

Status & tagging log