(bug 29392) Setting the start or end parameter now works with lists blocks, categorym...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Thu, 6 Oct 2011 20:46:24 +0000 (20:46 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Thu, 6 Oct 2011 20:46:24 +0000 (20:46 +0000)
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

RELEASE-NOTES-1.19
includes/api/ApiQueryBase.php
includes/api/ApiQueryBlocks.php
includes/api/ApiQueryDeletedrevs.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryProtectedTitles.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryRevisions.php
includes/api/ApiQueryUserContributions.php
includes/api/ApiQueryWatchlist.php

index 9321195..bcd37c7 100644 (file)
@@ -120,6 +120,9 @@ production.
 * (bug 26885) Allow show/hide of account blocks, temporary blocks and single IP
   address blocks for list=blocks.
 * (bug 30591) Add support to only return keys in ApiAllMessages.
+* (bug 29392) Setting the start or end parameter now works with lists blocks,
+  categorymembers, deletedrevs, logevents, protectedtitles, usercontributions 
+  and watchlist in Postgres
 
 === Languages updated in 1.19 ===
 
index 18a1a18..b7bb1a1 100644 (file)
@@ -220,6 +220,16 @@ abstract class ApiQueryBase extends ApiBase {
                        }
                }
        }
+       /**
+        * Add a WHERE clause corresponding to a range, similar to addWhereRange,
+        * but converts $start and $end to database timestamps.
+        * @see addWhereRange
+        */
+       protected function addTimestampWhereRange( $field, $dir, $start, $end, $sort = true ) {
+               $db = $this->getDb();
+               return $this->addWhereRange( $field, $dir, 
+                       $db->timestamp( $start ), $db->timestamp( $end ), $sort );
+       }
 
        /**
         * Add an option such as LIMIT or USE INDEX. If an option was set
index 83f8eb8..36f0896 100644 (file)
@@ -81,7 +81,7 @@ class ApiQueryBlocks extends ApiQueryBase {
                                                        $fld_flags );
 
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
-               $this->addWhereRange( 'ipb_timestamp', $params['dir'], $params['start'], $params['end'] );
+               $this->addTimestampWhereRange( 'ipb_timestamp', $params['dir'], $params['start'], $params['end'] );
                if ( isset( $params['ids'] ) ) {
                        $this->addWhereFld( 'ipb_id', $params['ids'] );
                }
index 813d98c..3ce962e 100644 (file)
@@ -191,7 +191,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                                $this->addWhereRange( 'ar_namespace', $dir, null, null );
                                $this->addWhereRange( 'ar_title', $dir, null, null );
                        }
-                       $this->addWhereRange( 'ar_timestamp', $dir, $params['start'], $params['end'] );
+                       $this->addTimestampWhereRange( 'ar_timestamp', $dir, $params['start'], $params['end'] );
                }
                $res = $this->select( __METHOD__ );
                $pageMap = array(); // Maps ns&title to (fake) pageid
index db75c8e..309c742 100644 (file)
@@ -116,7 +116,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        $index['logging'] = 'type_time';
                }
 
-               $this->addWhereRange( 'log_timestamp', $params['dir'], $params['start'], $params['end'] );
+               $this->addTimestampWhereRange( 'log_timestamp', $params['dir'], $params['start'], $params['end'] );
 
                $limit = $params['limit'];
                $this->addOption( 'LIMIT', $limit + 1 );
index 9330d18..f3b1436 100644 (file)
@@ -64,7 +64,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
                $this->addFieldsIf( 'pt_expiry', isset( $prop['expiry'] ) );
                $this->addFieldsIf( 'pt_create_perm', isset( $prop['level'] ) );
 
-               $this->addWhereRange( 'pt_timestamp', $params['dir'], $params['start'], $params['end'] );
+               $this->addTimestampWhereRange( 'pt_timestamp', $params['dir'], $params['start'], $params['end'] );
                $this->addWhereFld( 'pt_namespace', $params['namespace'] );
                $this->addWhereFld( 'pt_create_perm', $params['level'] );
 
index 79012cc..d955aaa 100644 (file)
@@ -140,7 +140,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                 */
                $this->addTables( 'recentchanges' );
                $index = array( 'recentchanges' => 'rc_timestamp' ); // May change
-               $this->addWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
+               $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
                $this->addWhereFld( 'rc_namespace', $params['namespace'] );
                $this->addWhereFld( 'rc_deleted', 0 );
 
index 5298d39..431cc27 100644 (file)
@@ -252,14 +252,14 @@ class ApiQueryRevisions extends ApiQueryBase {
                        // one row with the same timestamp for the same page.
                        // The order needs to be the same as start parameter to avoid SQL filesort.
                        if ( is_null( $params['startid'] ) && is_null( $params['endid'] ) ) {
-                               $this->addWhereRange( 'rev_timestamp', $params['dir'],
+                               $this->addTimestampWhereRange( 'rev_timestamp', $params['dir'],
                                        $params['start'], $params['end'] );
                        } else {
                                $this->addWhereRange( 'rev_id', $params['dir'],
                                        $params['startid'], $params['endid'] );
                                // One of start and end can be set
                                // If neither is set, this does nothing
-                               $this->addWhereRange( 'rev_timestamp', $params['dir'],
+                               $this->addTimestampWhereRange( 'rev_timestamp', $params['dir'],
                                        $params['start'], $params['end'], false );
                        }
 
index ba97864..62194a4 100644 (file)
@@ -182,7 +182,7 @@ class ApiQueryContributions extends ApiQueryBase {
                if ( $this->multiUserMode ) {
                        $this->addWhereRange( 'rev_user_text', $this->params['dir'], null, null );
                }
-               $this->addWhereRange( 'rev_timestamp',
+               $this->addTimestampWhereRange( 'rev_timestamp',
                        $this->params['dir'], $this->params['start'], $this->params['end'] );
                $this->addWhereFld( 'page_namespace', $this->params['namespace'] );
 
index 2e45fdf..76965ce 100644 (file)
@@ -134,9 +134,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
 
                $db = $this->getDB();
 
-               $this->addWhereRange( 'rc_timestamp', $params['dir'],
-                       $db->timestamp( $params['start'] ),
-                       $db->timestamp( $params['end'] ) );
+               $this->addTimestampWhereRange( 'rc_timestamp', $params['dir'], 
+                       $params['start'], $params['end'] );
                $this->addWhereFld( 'wl_namespace', $params['namespace'] );
 
                if ( !$params['allrev'] ) {