* (bug 28392) mark action=undelete&timestamps as type "timestamp"

Allow multiple timestamps
This commit is contained in:
Sam Reed 2011-06-05 23:18:22 +00:00
parent b5b6f83a7e
commit 587f480923
3 changed files with 22 additions and 8 deletions

View 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 ===

View file

@ -775,14 +775,13 @@ abstract class ApiBase {
}
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 ) ) {
@ -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
*

View 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',