API: Finish killing "raw mode"
authorBrad Jorsch <bjorsch@wikimedia.org>
Mon, 20 Apr 2015 18:58:55 +0000 (14:58 -0400)
committerAnomie <bjorsch@wikimedia.org>
Thu, 17 Sep 2015 13:51:45 +0000 (13:51 +0000)
It was kept around in the ApiResult rewrite because Wikibase was
(mis)using it as an "XML mode" flag.

Bug: T96596
Change-Id: Ic8259649c8cb0cce0444c907607c36d96fb2eb7e

includes/api/ApiFormatBase.php
includes/api/ApiFormatFeedWrapper.php
includes/api/ApiFormatJson.php
includes/api/ApiFormatXml.php
includes/api/ApiMain.php
includes/api/ApiResult.php
tests/phpunit/includes/api/ApiResultTest.php

index f54f20f..e522d70 100644 (file)
@@ -387,10 +387,11 @@ abstract class ApiFormatBase extends ApiBase {
         * are required to ignore it or filter it out.
         *
         * @deprecated since 1.25
-        * @return bool
+        * @return bool Always true
         */
        public function getNeedsRawData() {
-               return false;
+               wfDeprecated( __METHOD__, '1.25' );
+               return true;
        }
 
        /**@}*/
index 00747ee..d2bfd48 100644 (file)
@@ -59,15 +59,6 @@ class ApiFormatFeedWrapper extends ApiFormatBase {
                return null;
        }
 
-       /**
-        * Optimization - no need to sanitize data that will not be needed
-        *
-        * @return bool
-        */
-       public function getNeedsRawData() {
-               return true;
-       }
-
        /**
         * ChannelFeed doesn't give us a method to print errors in a friendly
         * manner, so just punt errors to the default printer.
index 9538842..be1b12c 100644 (file)
@@ -56,13 +56,6 @@ class ApiFormatJson extends ApiFormatBase {
                return 'application/json';
        }
 
-       /**
-        * @deprecated since 1.25
-        */
-       public function getNeedsRawData() {
-               return $this->isRaw;
-       }
-
        /**
         * @deprecated since 1.25
         */
index 4be7d93..e8ad387 100644 (file)
@@ -39,13 +39,6 @@ class ApiFormatXml extends ApiFormatBase {
                return 'text/xml';
        }
 
-       /**
-        * @deprecated since 1.25
-        */
-       public function getNeedsRawData() {
-               return true;
-       }
-
        public function setRootElement( $rootElemName ) {
                $this->mRootElemName = $rootElemName;
        }
index c558c2b..d943c86 100644 (file)
@@ -1203,10 +1203,6 @@ class ApiMain extends ApiBase {
                        // Create an appropriate printer
                        $this->mPrinter = $this->createPrinterByName( $params['format'] );
                }
-
-               if ( $this->mPrinter->getNeedsRawData() ) {
-                       $this->getResult()->setRawMode();
-               }
        }
 
        /**
index 142a780..cd4165b 100644 (file)
@@ -144,7 +144,7 @@ class ApiResult implements ApiSerializable {
        private $errorFormatter;
 
        // Deprecated fields
-       private $isRawMode, $checkingSize, $mainForContinuation;
+       private $checkingSize, $mainForContinuation;
 
        /**
         * @param int|bool $maxSize Maximum result "size", or false for no limit
@@ -159,7 +159,6 @@ class ApiResult implements ApiSerializable {
                }
 
                $this->maxSize = $maxSize;
-               $this->isRawMode = false;
                $this->checkingSize = true;
                $this->reset();
        }
@@ -1205,27 +1204,23 @@ class ApiResult implements ApiSerializable {
         */
 
        /**
-        * Call this function when special elements such as '_element'
-        * are needed by the formatter, for example in XML printing.
+        * Formerly used to enable/disable "raw mode".
         * @deprecated since 1.25, you shouldn't have been using it in the first place
         * @since 1.23 $flag parameter added
         * @param bool $flag Set the raw mode flag to this state
         */
        public function setRawMode( $flag = true ) {
-               // Can't wfDeprecated() here, since we need to set this flag from
-               // ApiMain for BC with stuff using self::getIsRawMode as
-               // "self::getIsXMLMode".
-               $this->isRawMode = $flag;
+               wfDeprecated( __METHOD__, '1.25' );
        }
 
        /**
-        * Returns true whether the formatter requested raw data.
+        * Returns true, the equivalent of "raw mode" is always enabled now
         * @deprecated since 1.25, you shouldn't have been using it in the first place
         * @return bool
         */
        public function getIsRawMode() {
-               /// @todo: After Wikibase stops calling this, warn
-               return $this->isRawMode;
+               wfDeprecated( __METHOD__, '1.25' );
+               return true;
        }
 
        /**
@@ -1238,7 +1233,7 @@ class ApiResult implements ApiSerializable {
                return $this->getResultData( null, array(
                        'BC' => array(),
                        'Types' => array(),
-                       'Strip' => $this->isRawMode ? 'bc' : 'all',
+                       'Strip' => 'all',
                ) );
        }
 
index cff2328..2f31677 100644 (file)
@@ -1321,17 +1321,6 @@ class ApiResultTest extends MediaWikiTestCase {
                        ),
                        '*' => 'content',
                ), $result->getData() );
-               $result->setRawMode();
-               $this->assertSame( array(
-                       'foo' => array(
-                               'bar' => array(
-                                       '*' => 'content',
-                               ),
-                       ),
-                       '*' => 'content',
-                       '_element' => 'itn',
-                       '_subelements' => array( 'sub' ),
-               ), $result->getData() );
 
                $arr = array();
                ApiResult::setContent( $arr, 'value' );