From 587f4809231c81406a385c6ce8dcec9d0966d8d2 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 5 Jun 2011 23:18:22 +0000 Subject: [PATCH] * (bug 28392) mark action=undelete×tamps as type "timestamp" Allow multiple timestamps --- RELEASE-NOTES-1.19 | 1 + includes/api/ApiBase.php | 26 +++++++++++++++++++------- includes/api/ApiUndelete.php | 3 ++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index d5417fce73..ef57e698dc 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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×tamps as type "timestamp" === Languages updated in 1.19 === diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 21f6d96c58..25e2701fde 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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 * diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php index 615b224628..509c1f825e 100644 --- a/includes/api/ApiUndelete.php +++ b/includes/api/ApiUndelete.php @@ -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', -- 2.20.1