Fix broken contribution listings with postgres by adding a new variable
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Tue, 28 Nov 2006 21:40:42 +0000 (21:40 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Tue, 28 Nov 2006 21:40:42 +0000 (21:40 +0000)
to check if we are using integers or explicit timestamps.

includes/Database.php
includes/DatabasePostgres.php
includes/SpecialContributions.php

index e707546..5f5601f 100644 (file)
@@ -250,6 +250,7 @@ class Database {
        protected $mCascadingDeletes = false;
        protected $mCleanupTriggers = false;
        protected $mStrictIPs = false;
+       protected $mRealTimestamps = false;
 
 #------------------------------------------------------------------------------
 # Accessors
@@ -362,6 +363,13 @@ class Database {
                return $this->mStrictIPs;
        }
 
+       /**
+        * Returns true if this database uses timestamps rather than integers
+       */
+       function realTimestamps() {
+               return $this->mRealTimestamps;
+       }
+
        /**#@+
         * Get function
         */
index 0ff74ed..805313d 100644 (file)
@@ -28,6 +28,7 @@ class DatabasePostgres extends Database {
                $this->mCascadingDeletes = true;
                $this->mCleanupTriggers = true;
                $this->mStrictIPs = true;
+               $this->mRealTimestamps = true;
                $this->mFlags = $flags;
                $this->open( $server, $user, $password, $dbName);
 
index f9fe14e..0907256 100644 (file)
@@ -185,9 +185,11 @@ function wfSpecialContributions( $par = null ) {
 
        list( $options['limit'], $options['offset']) = wfCheckLimits();
        $options['offset'] = $wgRequest->getVal( 'offset' );
-       /* Offset must be an integral. */
-       if ( !strlen( $options['offset'] ) || !preg_match( '/^[0-9]+$/', $options['offset'] ) )
-               $options['offset'] = '';
+       /* Offset must be an integral, unless the db is using timestamps */
+       $dbr =& wfGetDB( DB_SLAVE );
+       if ( !strlen( $options['offset'] ) ||
+               ( !$dbr->realTimestamps() && !preg_match( '/^[0-9]+$/', $options['offset'] ) ) )
+       $options['offset'] = '';
 
        $title = SpecialPage::getTitleFor( 'Contributions' );
        $options['target'] = $target;