http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89540

Revision: 89540
Author:   reedy
Date:     2011-06-05 23:18:22 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
* (bug 28392) mark action=undelete&timestamps as type "timestamp"

Allow multiple timestamps

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES-1.19
    trunk/phase3/includes/api/ApiBase.php
    trunk/phase3/includes/api/ApiUndelete.php

Modified: trunk/phase3/RELEASE-NOTES-1.19
===================================================================
--- trunk/phase3/RELEASE-NOTES-1.19     2011-06-05 22:51:58 UTC (rev 89539)
+++ trunk/phase3/RELEASE-NOTES-1.19     2011-06-05 23:18:22 UTC (rev 89540)
@@ -102,6 +102,7 @@
 * (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 ===
 

Modified: trunk/phase3/includes/api/ApiBase.php
===================================================================
--- trunk/phase3/includes/api/ApiBase.php       2011-06-05 22:51:58 UTC (rev 
89539)
+++ trunk/phase3/includes/api/ApiBase.php       2011-06-05 23:18:22 UTC (rev 
89540)
@@ -775,14 +775,13 @@
                                                }
                                                break;
                                        case 'timestamp':
-                                               if ( $multi ) {
-                                                       ApiBase::dieDebug( 
__METHOD__, "Multi-values not supported for $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_UNIX, 
$value );
-                                               if ( $value === 0 ) {
-                                                       $this->dieUsage( 
"Invalid value '$value' for timestamp parameter $encParamName", 
"badtimestamp_{$encParamName}" );
-                                               }
-                                               $value = wfTimestamp( TS_MW, 
$value );
                                                break;
                                        case 'user':
                                                if ( !is_array( $value ) ) {
@@ -914,6 +913,19 @@
        }
 
        /**
+        * @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
         *
         * @param  $msg String Message to show as a warning, or error message 
if dying

Modified: trunk/phase3/includes/api/ApiUndelete.php
===================================================================
--- trunk/phase3/includes/api/ApiUndelete.php   2011-06-05 22:51:58 UTC (rev 
89539)
+++ trunk/phase3/includes/api/ApiUndelete.php   2011-06-05 23:18:22 UTC (rev 
89540)
@@ -103,7 +103,8 @@
                        'token' => null,
                        'reason' => '',
                        'timestamps' => array(
-                               ApiBase::PARAM_ISMULTI => true
+                               ApiBase::PARAM_TYPE => 'timestamp',
+                               ApiBase::PARAM_ISMULTI => true,
                        ),
                        'watchlist' => array(
                                ApiBase::PARAM_DFLT => 'preferences',


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to