r80324 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80323‎ | r80324 | r80325 >
Date:21:08, 14 January 2011
Author:reedy
Status:ok
Tags:
Comment:
Start of bug 24650 Fix API to work with categorylinks changes

Addition of a type field for filtering (default is "all" ie no filter)

Adding of type to props, to allow it to be outputted
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -78,6 +78,7 @@
7979 $fld_title = isset( $prop['title'] );
8080 $fld_sortkey = isset( $prop['sortkey'] );
8181 $fld_timestamp = isset( $prop['timestamp'] );
 82+ $fld_type = isset( $prop['type'] );
8283
8384 if ( is_null( $resultPageSet ) ) {
8485 $this->addFields( array( 'cl_from', 'cl_sortkey', 'page_namespace', 'page_title' ) );
@@ -88,8 +89,10 @@
8990 }
9091
9192 $this->addFieldsIf( 'cl_timestamp', $fld_timestamp || $params['sort'] == 'timestamp' );
 93+ $this->addFieldsIf( 'cl_type', $fld_type );
9294 $this->addTables( array( 'page', 'categorylinks' ) ); // must be in this order for 'USE INDEX'
93 - // Not needed after bug 10280 is applied to servers
 95+
 96+ // Not needed after bug 10280 is applied to servers
9497 if ( $params['sort'] == 'timestamp' ) {
9598 $this->addOption( 'USE INDEX', 'cl_timestamp' );
9699 } else {
@@ -99,6 +102,9 @@
100103 $this->addWhere( 'cl_from=page_id' );
101104 $this->setContinuation( $params['continue'], $params['dir'] );
102105 $this->addWhereFld( 'cl_to', $categoryTitle->getDBkey() );
 106+
 107+ $this->addWhereFld( 'cl_type', $params['type'] );
 108+
103109 // Scanning large datasets for rare categories sucks, and I already told
104110 // how to have efficient subcategory access :-) ~~~~ (oh well, domas)
105111 global $wgMiserMode;
@@ -108,11 +114,21 @@
109115 } else {
110116 $this->addWhereFld( 'page_namespace', $params['namespace'] );
111117 }
 118+
 119+ $dir = $params['dir'] == 'asc' ? 'newer' : 'older';
 120+
112121 if ( $params['sort'] == 'timestamp' ) {
113 - $this->addWhereRange( 'cl_timestamp', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), $params['start'], $params['end'] );
 122+ $this->addWhereRange( 'cl_timestamp',
 123+ $dir,
 124+ $params['start'],
 125+ $params['end'] );
114126 } else {
115 - $this->addWhereRange( 'cl_sortkey', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), $params['startsortkey'], $params['endsortkey'] );
116 - $this->addWhereRange( 'cl_from', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), null, null );
 127+ $this->addWhereRange( 'cl_sortkey',
 128+ $dir,
 129+ $params['startsortkey'],
 130+ $params['endsortkey'] );
 131+
 132+ $this->addWhereRange( 'cl_from', $dir, null, null );
117133 }
118134
119135 $limit = $params['limit'];
@@ -153,6 +169,9 @@
154170 if ( $fld_sortkey ) {
155171 $vals['sortkey'] = $row->cl_sortkey;
156172 }
 173+ if ( $fld_type ) {
 174+ $vals['type'] = $row->cl_type;
 175+ }
157176 if ( $fld_timestamp ) {
158177 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp );
159178 }
@@ -231,6 +250,7 @@
232251 'ids',
233252 'title',
234253 'sortkey',
 254+ 'type',
235255 'timestamp',
236256 )
237257 ),
@@ -238,6 +258,15 @@
239259 ApiBase::PARAM_ISMULTI => true,
240260 ApiBase::PARAM_TYPE => 'namespace',
241261 ),
 262+ 'type' => array(
 263+ ApiBase::PARAM_ISMULTI => true,
 264+ ApiBase::PARAM_DFLT => 'page|subcat|file',
 265+ ApiBase::PARAM_TYPE => array(
 266+ 'page',
 267+ 'subcat',
 268+ 'file'
 269+ )
 270+ ),
242271 'continue' => null,
243272 'limit' => array(
244273 ApiBase::PARAM_TYPE => 'limit',
@@ -285,6 +314,7 @@
286315 ' timestamp - Adds the timestamp of when the page was included',
287316 ),
288317 'namespace' => 'Only include pages in these namespaces',
 318+ 'type' => 'What type of category members to include',
289319 'sort' => 'Property to sort by',
290320 'dir' => 'In which direction to sort',
291321 'start' => "Timestamp to start listing from. Can only be used with {$p}sort=timestamp",

Follow-up revisions

RevisionCommit summaryAuthorDate
r80326Followup r80324, add type property descriptionreedy21:15, 14 January 2011
r80358More for bug 24650. Update continue to be usable unique thingreedy00:00, 15 January 2011
r80362Last bits of bug 24650 Fix API to work with categorylinks changes...reedy00:10, 15 January 2011
r80363* (bug 24650) Fix API to work with categorylinks changes...reedy00:13, 15 January 2011
r80540Various fixes for API category changes:...catrope00:13, 19 January 2011
r807221.17: MFT r80324, r80326, r80328, r80339, r80350, r80351, r80355, r80358, r80...catrope23:00, 21 January 2011
r81671Back out the changes which depend on the categorylinks schema change, so that...tstarling00:57, 8 February 2011

Status & tagging log