r99138 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99137‎ | r99138 | r99139 >
Date:20:46, 6 October 2011
Author:btongminh
Status:ok (Comments)
Tags:
Comment:
(bug 29392) Setting the start or end parameter now works with lists blocks, categorymembers, deletedrevs, logevents, protectedtitles, usercontributions and watchlist in Postgres.
Since all those used ApiQueryBase::addWhereRange, added ApiQueryBase::addTimestampWhereRange, which does automagic timestamp conversion. Not tested whether this actually fixes problems in Postgres, but at least the API modules are still functional in SQLite
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBlocks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryDeletedrevs.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLogEvents.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryProtectedTitles.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryRecentChanges.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryRevisions.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryUserContributions.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -120,6 +120,9 @@
121121 * (bug 26885) Allow show/hide of account blocks, temporary blocks and single IP
122122 address blocks for list=blocks.
123123 * (bug 30591) Add support to only return keys in ApiAllMessages.
 124+* (bug 29392) Setting the start or end parameter now works with lists blocks,
 125+ categorymembers, deletedrevs, logevents, protectedtitles, usercontributions
 126+ and watchlist in Postgres
124127
125128 === Languages updated in 1.19 ===
126129
Index: trunk/phase3/includes/api/ApiQueryRecentChanges.php
@@ -140,7 +140,7 @@
141141 */
142142 $this->addTables( 'recentchanges' );
143143 $index = array( 'recentchanges' => 'rc_timestamp' ); // May change
144 - $this->addWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
 144+ $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
145145 $this->addWhereFld( 'rc_namespace', $params['namespace'] );
146146 $this->addWhereFld( 'rc_deleted', 0 );
147147
Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php
@@ -191,7 +191,7 @@
192192 $this->addWhereRange( 'ar_namespace', $dir, null, null );
193193 $this->addWhereRange( 'ar_title', $dir, null, null );
194194 }
195 - $this->addWhereRange( 'ar_timestamp', $dir, $params['start'], $params['end'] );
 195+ $this->addTimestampWhereRange( 'ar_timestamp', $dir, $params['start'], $params['end'] );
196196 }
197197 $res = $this->select( __METHOD__ );
198198 $pageMap = array(); // Maps ns&title to (fake) pageid
Index: trunk/phase3/includes/api/ApiQueryBase.php
@@ -220,6 +220,16 @@
221221 }
222222 }
223223 }
 224+ /**
 225+ * Add a WHERE clause corresponding to a range, similar to addWhereRange,
 226+ * but converts $start and $end to database timestamps.
 227+ * @see addWhereRange
 228+ */
 229+ protected function addTimestampWhereRange( $field, $dir, $start, $end, $sort = true ) {
 230+ $db = $this->getDb();
 231+ return $this->addWhereRange( $field, $dir,
 232+ $db->timestamp( $start ), $db->timestamp( $end ), $sort );
 233+ }
224234
225235 /**
226236 * Add an option such as LIMIT or USE INDEX. If an option was set
Index: trunk/phase3/includes/api/ApiQueryBlocks.php
@@ -81,7 +81,7 @@
8282 $fld_flags );
8383
8484 $this->addOption( 'LIMIT', $params['limit'] + 1 );
85 - $this->addWhereRange( 'ipb_timestamp', $params['dir'], $params['start'], $params['end'] );
 85+ $this->addTimestampWhereRange( 'ipb_timestamp', $params['dir'], $params['start'], $params['end'] );
8686 if ( isset( $params['ids'] ) ) {
8787 $this->addWhereFld( 'ipb_id', $params['ids'] );
8888 }
Index: trunk/phase3/includes/api/ApiQueryLogEvents.php
@@ -116,7 +116,7 @@
117117 $index['logging'] = 'type_time';
118118 }
119119
120 - $this->addWhereRange( 'log_timestamp', $params['dir'], $params['start'], $params['end'] );
 120+ $this->addTimestampWhereRange( 'log_timestamp', $params['dir'], $params['start'], $params['end'] );
121121
122122 $limit = $params['limit'];
123123 $this->addOption( 'LIMIT', $limit + 1 );
Index: trunk/phase3/includes/api/ApiQueryProtectedTitles.php
@@ -64,7 +64,7 @@
6565 $this->addFieldsIf( 'pt_expiry', isset( $prop['expiry'] ) );
6666 $this->addFieldsIf( 'pt_create_perm', isset( $prop['level'] ) );
6767
68 - $this->addWhereRange( 'pt_timestamp', $params['dir'], $params['start'], $params['end'] );
 68+ $this->addTimestampWhereRange( 'pt_timestamp', $params['dir'], $params['start'], $params['end'] );
6969 $this->addWhereFld( 'pt_namespace', $params['namespace'] );
7070 $this->addWhereFld( 'pt_create_perm', $params['level'] );
7171
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php
@@ -134,9 +134,8 @@
135135
136136 $db = $this->getDB();
137137
138 - $this->addWhereRange( 'rc_timestamp', $params['dir'],
139 - $db->timestamp( $params['start'] ),
140 - $db->timestamp( $params['end'] ) );
 138+ $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'],
 139+ $params['start'], $params['end'] );
141140 $this->addWhereFld( 'wl_namespace', $params['namespace'] );
142141
143142 if ( !$params['allrev'] ) {
Index: trunk/phase3/includes/api/ApiQueryRevisions.php
@@ -252,14 +252,14 @@
253253 // one row with the same timestamp for the same page.
254254 // The order needs to be the same as start parameter to avoid SQL filesort.
255255 if ( is_null( $params['startid'] ) && is_null( $params['endid'] ) ) {
256 - $this->addWhereRange( 'rev_timestamp', $params['dir'],
 256+ $this->addTimestampWhereRange( 'rev_timestamp', $params['dir'],
257257 $params['start'], $params['end'] );
258258 } else {
259259 $this->addWhereRange( 'rev_id', $params['dir'],
260260 $params['startid'], $params['endid'] );
261261 // One of start and end can be set
262262 // If neither is set, this does nothing
263 - $this->addWhereRange( 'rev_timestamp', $params['dir'],
 263+ $this->addTimestampWhereRange( 'rev_timestamp', $params['dir'],
264264 $params['start'], $params['end'], false );
265265 }
266266
Index: trunk/phase3/includes/api/ApiQueryUserContributions.php
@@ -182,7 +182,7 @@
183183 if ( $this->multiUserMode ) {
184184 $this->addWhereRange( 'rev_user_text', $this->params['dir'], null, null );
185185 }
186 - $this->addWhereRange( 'rev_timestamp',
 186+ $this->addTimestampWhereRange( 'rev_timestamp',
187187 $this->params['dir'], $this->params['start'], $this->params['end'] );
188188 $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
189189

Follow-up revisions

RevisionCommit summaryAuthorDate
r99236Follow-up r84765, use timestampOrNullbtongminh19:11, 7 October 2011
r100379REL1_18 MFT r99135, r99136, r99138, r99154, r99172, r99250, r99252, r99254, r...reedy21:22, 20 October 2011
r100380After r100379, move release notes for bug 29392reedy21:22, 20 October 2011

Comments

#Comment by Bryan (talk | contribs)   20:48, 6 October 2011

Unbreaks a lot of API stuff with Postgres. Backport?

#Comment by Aaron Schulz (talk | contribs)   20:53, 6 October 2011

REL 1.18 yes.

#Comment by Catrope (talk | contribs)   14:57, 8 October 2011

Awesome, thanks!

Status & tagging log