r88792 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88791‎ | r88792 | r88793 >
Date:14:29, 25 May 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
adding merge param
Modified paths:
  • /trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php
@@ -35,7 +35,7 @@
3636
3737 $sets = $this->select( __METHOD__ );
3838 $count = 0;
39 - $resultSets = array();
 39+ $resultSets = array();
4040
4141 foreach ( $sets as $set ) {
4242 if ( ++$count > $params['limit'] ) {
@@ -45,17 +45,23 @@
4646 break;
4747 }
4848
49 - $set = SWLChangeSet::newFromDBResult( $set )->toArray();
 49+ $resultSets[] = SWLChangeSet::newFromDBResult( $set );
 50+ }
 51+
 52+ if ( $params['merge'] ) {
 53+ $this->mergeSets( $resultSets );
 54+ }
 55+
 56+ $this->getResult()->setIndexedTagName( $resultSets, 'set' );
 57+
 58+ foreach ( $resultSets as &$set ) {
 59+ $set = $set->toArray();
5060
5161 foreach ( $set['changes'] as $propName => $changes ) {
5262 $this->getResult()->setIndexedTagName( $set['changes'][$propName], 'change' );
5363 }
54 -
55 - $resultSets[] = $set;
5664 }
5765
58 - $this->getResult()->setIndexedTagName( $resultSets, 'set' );
59 -
6066 $this->getResult()->addValue(
6167 null,
6268 'sets',
@@ -120,9 +126,20 @@
121127 // TODO: error
122128 }
123129 }
124 - }
 130+ }
125131
126132 /**
 133+ * Merge change sets belonging to the same edit into one sinlge change set.
 134+ *
 135+ * @since 0.1
 136+ *
 137+ * @param array $sets
 138+ */
 139+ protected function mergeSets( array &$sets ) {
 140+ // TODO
 141+ }
 142+
 143+ /**
127144 * (non-PHPdoc)
128145 * @see includes/api/ApiBase#getAllowedParams()
129146 */
@@ -158,6 +175,7 @@
159176 return array (
160177 'userid' => 'The ID of the user for which to return semantic watchlist data.',
161178 'groupids' => 'The IDs of the groups for which to return semantic watchlist data.',
 179+ 'merge' => 'Merge sets of changes that belong to the same edit?',
162180 'continue' => 'Offset number from where to continue the query',
163181 'limit' => 'Max amount of words to return',
164182 );

Status & tagging log