}
public function execute() {
- $text = serialize( $this->getResultData() );
+ $params = $this->extractRequestParams();
+
+ switch ( $params['formatversion'] ) {
+ case 1:
+ $transforms = array(
+ 'BC' => array(),
+ 'Types' => array(),
+ 'Strip' => 'all',
+ );
+ break;
+
+ case 2:
+ case 'latest':
+ $transforms = array(
+ 'Types' => array(),
+ 'Strip' => 'all',
+ );
+ break;
+
+ default:
+ $this->dieUsage( __METHOD__ . ': Unknown value for \'formatversion\'', 'unknownformatversion' );
+ }
+ $text = serialize( $this->getResult()->getResultData( null, $transforms ) );
// Bug 66776: wfMangleFlashPolicy() is needed to avoid a nasty bug in
// Flash, but what it does isn't friendly for the API. There's nothing
preg_match( '/\<\s*cross-domain-policy\s*\>/i', $text )
) {
$this->dieUsage(
- 'This response cannot be represented using format=php. See https://bugzilla.wikimedia.org/show_bug.cgi?id=66776',
+ 'This response cannot be represented using format=php. ' .
+ 'See https://phabricator.wikimedia.org/T68776',
'internalerror'
);
}
$this->printText( $text );
}
+
+ public function getAllowedParams() {
+ $ret = array(
+ 'formatversion' => array(
+ ApiBase::PARAM_TYPE => array( 1, 2, 'latest' ),
+ ApiBase::PARAM_DFLT => 1,
+ ApiBase::PARAM_HELP_MSG => 'apihelp-php-param-formatversion',
+ ),
+ );
+ return $ret;
+ }
}