r89540 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89539‎ | r89540 | r89541 >
Date:23:18, 5 June 2011
Author:reedy
Status:ok
Tags:
Comment:
* (bug 28392) mark action=undelete&timestamps as type "timestamp"

Allow multiple timestamps
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUndelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -102,6 +102,7 @@
103103 * (bug 26597) Allow toggling of persistent cookies ("remember me") in API
104104 action=login
105105 * (bug 29237) add interwiki target url attribute to api/query/interwiki
 106+* (bug 28392) mark action=undelete&timestamps as type "timestamp"
106107
107108 === Languages updated in 1.19 ===
108109
Index: trunk/phase3/includes/api/ApiUndelete.php
@@ -103,7 +103,8 @@
104104 'token' => null,
105105 'reason' => '',
106106 'timestamps' => array(
107 - ApiBase::PARAM_ISMULTI => true
 107+ ApiBase::PARAM_TYPE => 'timestamp',
 108+ ApiBase::PARAM_ISMULTI => true,
108109 ),
109110 'watchlist' => array(
110111 ApiBase::PARAM_DFLT => 'preferences',
Index: trunk/phase3/includes/api/ApiBase.php
@@ -775,14 +775,13 @@
776776 }
777777 break;
778778 case 'timestamp':
779 - if ( $multi ) {
780 - ApiBase::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
 779+ if ( is_array( $value ) ) {
 780+ foreach ( $value as $key => $val ) {
 781+ $value[$key] = $this->validateTimestamp( $val, $encParamName );
 782+ }
 783+ } else {
 784+ $value = $this->validateTimestamp( $value, $encParamName );
781785 }
782 - $value = wfTimestamp( TS_UNIX, $value );
783 - if ( $value === 0 ) {
784 - $this->dieUsage( "Invalid value '$value' for timestamp parameter $encParamName", "badtimestamp_{$encParamName}" );
785 - }
786 - $value = wfTimestamp( TS_MW, $value );
787786 break;
788787 case 'user':
789788 if ( !is_array( $value ) ) {
@@ -914,6 +913,19 @@
915914 }
916915
917916 /**
 917+ * @param $value string
 918+ * @param $paramName string
 919+ * @return string
 920+ */
 921+ function validateTimestamp( $value, $paramName ) {
 922+ $value = wfTimestamp( TS_UNIX, $value );
 923+ if ( $value === 0 ) {
 924+ $this->dieUsage( "Invalid value '$value' for timestamp parameter $paramName", "badtimestamp_{$paramName}" );
 925+ }
 926+ return wfTimestamp( TS_MW, $value );
 927+ }
 928+
 929+ /**
918930 * Adds a warning to the output, else dies
919931 *
920932 * @param $msg String Message to show as a warning, or error message if dying

Status & tagging log