From f9c1bfa594a8848ca3d845716929d34fde0a7155 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Mon, 20 Apr 2015 14:58:55 -0400 Subject: [PATCH] API: Finish killing "raw mode" 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 | 5 +++-- includes/api/ApiFormatFeedWrapper.php | 9 --------- includes/api/ApiFormatJson.php | 7 ------- includes/api/ApiFormatXml.php | 7 ------- includes/api/ApiMain.php | 4 ---- includes/api/ApiResult.php | 19 +++++++------------ tests/phpunit/includes/api/ApiResultTest.php | 11 ----------- 7 files changed, 10 insertions(+), 52 deletions(-) diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index f54f20fc57..e522d709f1 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -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; } /**@}*/ diff --git a/includes/api/ApiFormatFeedWrapper.php b/includes/api/ApiFormatFeedWrapper.php index 00747eef59..d2bfd48d33 100644 --- a/includes/api/ApiFormatFeedWrapper.php +++ b/includes/api/ApiFormatFeedWrapper.php @@ -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. diff --git a/includes/api/ApiFormatJson.php b/includes/api/ApiFormatJson.php index 9538842466..be1b12c358 100644 --- a/includes/api/ApiFormatJson.php +++ b/includes/api/ApiFormatJson.php @@ -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 */ diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index 4be7d93df4..e8ad387bc3 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -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; } diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index c558c2b455..d943c86b42 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -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(); - } } /** diff --git a/includes/api/ApiResult.php b/includes/api/ApiResult.php index 142a780221..cd4165b603 100644 --- a/includes/api/ApiResult.php +++ b/includes/api/ApiResult.php @@ -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', ) ); } diff --git a/tests/phpunit/includes/api/ApiResultTest.php b/tests/phpunit/includes/api/ApiResultTest.php index cff2328dc8..2f31677e70 100644 --- a/tests/phpunit/includes/api/ApiResultTest.php +++ b/tests/phpunit/includes/api/ApiResultTest.php @@ -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' ); -- 2.20.1