* (bug 28392) mark action=undelete&timestamps as type "timestamp"
authorSam Reed <reedy@users.mediawiki.org>
Sun, 5 Jun 2011 23:18:22 +0000 (23:18 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 5 Jun 2011 23:18:22 +0000 (23:18 +0000)
Allow multiple timestamps

RELEASE-NOTES-1.19
includes/api/ApiBase.php
includes/api/ApiUndelete.php

index d5417fc..ef57e69 100644 (file)
@@ -102,6 +102,7 @@ production.
 * (bug 26597) Allow toggling of persistent cookies ("remember me") in API
   action=login
 * (bug 29237) add interwiki target url attribute to api/query/interwiki
+* (bug 28392) mark action=undelete&timestamps as type "timestamp"
 
 === Languages updated in 1.19 ===
 
index 21f6d96..25e2701 100644 (file)
@@ -775,14 +775,13 @@ abstract class ApiBase {
                                                }
                                                break;
                                        case 'timestamp':
-                                               if ( $multi ) {
-                                                       ApiBase::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
-                                               }
-                                               $value = wfTimestamp( TS_UNIX, $value );
-                                               if ( $value === 0 ) {
-                                                       $this->dieUsage( "Invalid value '$value' for timestamp parameter $encParamName", "badtimestamp_{$encParamName}" );
+                                               if ( is_array( $value ) ) {
+                                                       foreach ( $value as $key => $val ) {
+                                                               $value[$key] = $this->validateTimestamp( $val, $encParamName );
+                                                       }
+                                               } else {
+                                                       $value = $this->validateTimestamp( $value, $encParamName );
                                                }
-                                               $value = wfTimestamp( TS_MW, $value );
                                                break;
                                        case 'user':
                                                if ( !is_array( $value ) ) {
@@ -913,6 +912,19 @@ abstract class ApiBase {
                }
        }
 
+       /**
+        * @param $value string
+        * @param $paramName string
+        * @return string
+        */
+       function validateTimestamp( $value, $paramName ) {
+               $value = wfTimestamp( TS_UNIX, $value );
+               if ( $value === 0 ) {
+                       $this->dieUsage( "Invalid value '$value' for timestamp parameter $paramName", "badtimestamp_{$paramName}" );
+               }
+               return wfTimestamp( TS_MW, $value );
+       }
+
        /**
         * Adds a warning to the output, else dies
         *
index 615b224..509c1f8 100644 (file)
@@ -103,7 +103,8 @@ class ApiUndelete extends ApiBase {
                        'token' => null,
                        'reason' => '',
                        'timestamps' => array(
-                               ApiBase::PARAM_ISMULTI => true
+                               ApiBase::PARAM_TYPE => 'timestamp',
+                               ApiBase::PARAM_ISMULTI => true,
                        ),
                        'watchlist' => array(
                                ApiBase::PARAM_DFLT => 'preferences',