X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFormatPhp.php;h=df9d581f066640d77d8df43564cf0ee39878a18c;hb=9499586028e427a66cab01e550149b98e6e780a6;hp=a4b4a11d61725f7fed141f95c12d56190d564402;hpb=4d78d40d821227a9368e87306f447ffd3be5db88;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFormatPhp.php b/includes/api/ApiFormatPhp.php index a4b4a11d61..df9d581f06 100644 --- a/includes/api/ApiFormatPhp.php +++ b/includes/api/ApiFormatPhp.php @@ -35,7 +35,29 @@ class ApiFormatPhp extends ApiFormatBase { } 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 @@ -46,11 +68,23 @@ class ApiFormatPhp extends ApiFormatBase { 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; + } }