Some bugzilla.wikimedia.org -> phabricator.wikimedia.org changes
[lhc/web/wiklou.git] / includes / api / ApiFormatPhp.php
index a4b4a11..df9d581 100644 (file)
@@ -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;
+       }
 }