API: Add wfDeprecated() to deprecated ApiResult methods
[lhc/web/wiklou.git] / includes / api / ApiFormatPhp.php
index a4b4a11..d88dd40 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
@@ -53,4 +75,15 @@ class ApiFormatPhp extends ApiFormatBase {
 
                $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;
+       }
 }