From: Greg Sabino Mullane Date: Tue, 28 Nov 2006 21:40:42 +0000 (+0000) Subject: Fix broken contribution listings with postgres by adding a new variable X-Git-Tag: 1.31.0-rc.0~55048 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=38dd316259194d158f128fb90049df8c29bdb6d5;p=lhc%2Fweb%2Fwiklou.git Fix broken contribution listings with postgres by adding a new variable to check if we are using integers or explicit timestamps. --- diff --git a/includes/Database.php b/includes/Database.php index e707546352..5f5601f101 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -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 */ diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index 0ff74edfb9..805313dab9 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -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); diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index f9fe14ef29..090725642f 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -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;