fixed timestamp validation for api

wfTimestamp returns false on failure.

Renamed variable to output original input on failure and not the false

Change-Id: I39d31f35dae88b8a6e50ebee76a3be8722603ef3
This commit is contained in:
umherirrender 2013-01-05 21:09:16 +01:00
parent fb1d2fe219
commit b65a72da0b

View file

@ -1152,11 +1152,11 @@ abstract class ApiBase extends ContextSource {
* @return string
*/
function validateTimestamp( $value, $paramName ) {
$value = wfTimestamp( TS_UNIX, $value );
if ( $value === 0 ) {
$unixTimestamp = wfTimestamp( TS_UNIX, $value );
if ( $unixTimestamp === false ) {
$this->dieUsage( "Invalid value '$value' for timestamp parameter $paramName", "badtimestamp_{$paramName}" );
}
return wfTimestamp( TS_MW, $value );
return wfTimestamp( TS_MW, $unixTimestamp );
}
/**