Allow for timestamps in offset clause in non-integer-datetime databases.
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Thu, 1 Mar 2007 16:30:15 +0000 (16:30 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Thu, 1 Mar 2007 16:30:15 +0000 (16:30 +0000)
Fixes bug 9131.

includes/SpecialContributions.php

index c3e31e9..c6cd322 100644 (file)
@@ -213,9 +213,18 @@ 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 either be numeric, or a "standard" timestamp */
+    $dbr = wfGetDB( DB_SLAVE );
+    if ( !strlen( $options['offset'] )
+        || ($dbr->realTimestamps()
+            && !preg_match ( '/^\d\d\d\d\-\d\d\-\d\d \d\d:\d\d:\d\d(?:[+-]\d\d)?$/', $options['offset'] )
+           )
+        || (!$dbr->realTimestamps()
+            && !preg_match( '/^[0-9]+$/', $options['offset'] )
+           )
+       )
+       $options['offset'] = '';
 
        $title = SpecialPage::getTitleFor( 'Contributions' );
        $options['target'] = $target;