From 42e257a1a28c3b381eb1f6002e4b6417fc85d8a4 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 12 Nov 2015 12:58:46 -0500 Subject: [PATCH] API: Remove dbg, txt, and yaml formats Per RFC: https://www.mediawiki.org/wiki/Requests_for_comment/Ditch_crappy_API_formats Bug: T95715 Change-Id: I8e4e9ad3c96504cf4587cb4632504eff21b5ff75 --- RELEASE-NOTES-1.27 | 6 ++ autoload.php | 3 - includes/api/ApiFormatBase.php | 12 --- includes/api/ApiFormatDbg.php | 54 ----------- includes/api/ApiFormatTxt.php | 54 ----------- includes/api/ApiFormatYaml.php | 46 ---------- includes/api/ApiMain.php | 6 -- includes/api/i18n/en.json | 6 -- includes/api/i18n/qqq.json | 6 -- .../includes/api/format/ApiFormatDbgTest.php | 92 ------------------- .../includes/api/format/ApiFormatTxtTest.php | 57 ------------ 11 files changed, 6 insertions(+), 336 deletions(-) delete mode 100644 includes/api/ApiFormatDbg.php delete mode 100644 includes/api/ApiFormatTxt.php delete mode 100644 includes/api/ApiFormatYaml.php delete mode 100644 tests/phpunit/includes/api/format/ApiFormatDbgTest.php delete mode 100644 tests/phpunit/includes/api/format/ApiFormatTxtTest.php diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27 index e426e83941..5e5a236c02 100644 --- a/RELEASE-NOTES-1.27 +++ b/RELEASE-NOTES-1.27 @@ -52,6 +52,7 @@ production. * (T27397) WebP is enabled by default as an uploadable filetype. * (T48998) $wgArticlePath must now be either a full url, or start with a "/". * $wgRateLimitLog was removed; use $wgDebugLogGroups['ratelimit'] instead. +* Deprecated API formats dbg, txt, and yaml have been removed. === New features in 1.27 === * $wgDataCenterId and $wgDataCenterRoles where added, which will serve as @@ -96,9 +97,14 @@ production. "was-deleted" warning. * Added difftotextpst to query=revisions which preforms a pre-save transform on the text before diffing it. +* Deprecated formats dbg, txt, and yaml have been removed. === Action API internal changes in 1.27 === * ApiQueryORM removed. +* The following classes have been removed: +** ApiFormatDbg +** ApiFormatTxt +** ApiFormatYaml === Languages updated in 1.27 === diff --git a/autoload.php b/autoload.php index 15f1b10ebf..190555af64 100644 --- a/autoload.php +++ b/autoload.php @@ -36,16 +36,13 @@ $wgAutoloadLocalClasses = array( 'ApiFeedWatchlist' => __DIR__ . '/includes/api/ApiFeedWatchlist.php', 'ApiFileRevert' => __DIR__ . '/includes/api/ApiFileRevert.php', 'ApiFormatBase' => __DIR__ . '/includes/api/ApiFormatBase.php', - 'ApiFormatDbg' => __DIR__ . '/includes/api/ApiFormatDbg.php', 'ApiFormatFeedWrapper' => __DIR__ . '/includes/api/ApiFormatFeedWrapper.php', 'ApiFormatJson' => __DIR__ . '/includes/api/ApiFormatJson.php', 'ApiFormatNone' => __DIR__ . '/includes/api/ApiFormatNone.php', 'ApiFormatPhp' => __DIR__ . '/includes/api/ApiFormatPhp.php', 'ApiFormatRaw' => __DIR__ . '/includes/api/ApiFormatRaw.php', - 'ApiFormatTxt' => __DIR__ . '/includes/api/ApiFormatTxt.php', 'ApiFormatXml' => __DIR__ . '/includes/api/ApiFormatXml.php', 'ApiFormatXmlRsd' => __DIR__ . '/includes/api/ApiRsd.php', - 'ApiFormatYaml' => __DIR__ . '/includes/api/ApiFormatYaml.php', 'ApiHelp' => __DIR__ . '/includes/api/ApiHelp.php', 'ApiHelpParamValueMessage' => __DIR__ . '/includes/api/ApiHelpParamValueMessage.php', 'ApiImageRotate' => __DIR__ . '/includes/api/ApiImageRotate.php', diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index 17966afa0d..be683105ff 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -245,18 +245,6 @@ abstract class ApiFormatBase extends ApiBase { return 'https://www.mediawiki.org/wiki/API:Data_formats'; } - /** - * To avoid code duplication with the deprecation of dbg, txt - * and yaml, this method is added to do the necessary work. It should be - * removed when those deprecated formats are removed. - */ - protected function markDeprecated() { - $fm = $this->getIsHtml() ? 'fm' : ''; - $name = $this->getModuleName(); - $this->logFeatureUsage( "format=$name" ); - $this->setWarning( "format=$name has been deprecated. Please use format=json$fm instead." ); - } - /************************************************************************//** * @name Deprecated * @{ diff --git a/includes/api/ApiFormatDbg.php b/includes/api/ApiFormatDbg.php deleted file mode 100644 index 7d359ad45a..0000000000 --- a/includes/api/ApiFormatDbg.php +++ /dev/null @@ -1,54 +0,0 @@ -.@gmail.com" - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - */ - -/** - * API PHP's var_export() output formatter - * @deprecated since 1.24 - * @ingroup API - */ -class ApiFormatDbg extends ApiFormatBase { - - public function getMimeType() { - // This looks like it should be text/plain, but IE7 is so - // brain-damaged it tries to parse text/plain as HTML if it - // contains HTML tags. Using MIME text/text works around this bug - return 'text/text'; - } - - public function execute() { - $this->markDeprecated(); - $data = $this->getResult()->getResultData( null, array( - 'BC' => array(), - 'Types' => array(), - 'Strip' => 'all', - ) ); - $this->printText( var_export( $data, true ) ); - } - - public function isDeprecated() { - return true; - } -} diff --git a/includes/api/ApiFormatTxt.php b/includes/api/ApiFormatTxt.php deleted file mode 100644 index e739d5a4c0..0000000000 --- a/includes/api/ApiFormatTxt.php +++ /dev/null @@ -1,54 +0,0 @@ -.@gmail.com" - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - */ - -/** - * API Text output formatter - * @deprecated since 1.24 - * @ingroup API - */ -class ApiFormatTxt extends ApiFormatBase { - - public function getMimeType() { - // This looks like it should be text/plain, but IE7 is so - // brain-damaged it tries to parse text/plain as HTML if it - // contains HTML tags. Using MIME text/text works around this bug - return 'text/text'; - } - - public function execute() { - $this->markDeprecated(); - $data = $this->getResult()->getResultData( null, array( - 'BC' => array(), - 'Types' => array(), - 'Strip' => 'all', - ) ); - $this->printText( print_r( $data, true ) ); - } - - public function isDeprecated() { - return true; - } -} diff --git a/includes/api/ApiFormatYaml.php b/includes/api/ApiFormatYaml.php deleted file mode 100644 index c9089a7d04..0000000000 --- a/includes/api/ApiFormatYaml.php +++ /dev/null @@ -1,46 +0,0 @@ -@gmail.com" - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - */ - -/** - * API YAML output formatter - * @deprecated since 1.24 - * @ingroup API - */ -class ApiFormatYaml extends ApiFormatJson { - - public function getMimeType() { - return 'application/yaml'; - } - - public function execute() { - $this->markDeprecated(); - parent::execute(); - } - - public function isDeprecated() { - return true; - } -} diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 9d983d9a4f..ca5e1bbe4b 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -102,13 +102,7 @@ class ApiMain extends ApiBase { 'phpfm' => 'ApiFormatPhp', 'xml' => 'ApiFormatXml', 'xmlfm' => 'ApiFormatXml', - 'yaml' => 'ApiFormatYaml', - 'yamlfm' => 'ApiFormatYaml', 'rawfm' => 'ApiFormatJson', - 'txt' => 'ApiFormatTxt', - 'txtfm' => 'ApiFormatTxt', - 'dbg' => 'ApiFormatDbg', - 'dbgfm' => 'ApiFormatDbg', 'none' => 'ApiFormatNone', ); diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index c58be5b23e..4c2d0be0f0 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -1358,8 +1358,6 @@ "apihelp-watch-example-generator": "Watch the first few pages in the main namespace.", "apihelp-format-example-generic": "Return the query result in the $1 format.", - "apihelp-dbg-description": "Output data in PHP's var_export() format.", - "apihelp-dbgfm-description": "Output data in PHP's var_export() format (pretty-print in HTML).", "apihelp-json-description": "Output data in JSON format.", "apihelp-json-param-callback": "If specified, wraps the output into a given function call. For safety, all user-specific data will be restricted.", "apihelp-json-param-utf8": "If specified, encodes most (but not all) non-ASCII characters as UTF-8 instead of replacing them with hexadecimal escape sequences. Default when formatversion is not 1.", @@ -1371,14 +1369,10 @@ "apihelp-php-param-formatversion": "Output formatting:\n;1:Backwards-compatible format (XML-style booleans, * keys for content nodes, etc.).\n;2:Experimental modern format. Details may change!\n;latest:Use the latest format (currently 2), may change without warning.", "apihelp-phpfm-description": "Output data in serialized PHP format (pretty-print in HTML).", "apihelp-rawfm-description": "Output data, including debugging elements, in JSON format (pretty-print in HTML).", - "apihelp-txt-description": "Output data in PHP's print_r() format.", - "apihelp-txtfm-description": "Output data in PHP's print_r() format (pretty-print in HTML).", "apihelp-xml-description": "Output data in XML format.", "apihelp-xml-param-xslt": "If specified, adds the named page as an XSL stylesheet. The value must be a title in the {{ns:mediawiki}} namespace ending in .xsl.", "apihelp-xml-param-includexmlnamespace": "If specified, adds an XML namespace.", "apihelp-xmlfm-description": "Output data in XML format (pretty-print in HTML).", - "apihelp-yaml-description": "Output data in YAML format.", - "apihelp-yamlfm-description": "Output data in YAML format (pretty-print in HTML).", "api-format-title": "MediaWiki API result", "api-format-prettyprint-header": "This is the HTML representation of the $1 format. HTML is good for debugging, but is unsuitable for application use.\n\nSpecify the format parameter to change the output format. To see the non-HTML representation of the $1 format, set format=$2.\n\nSee the [[mw:API|complete documentation]], or the [[Special:ApiHelp/main|API help]] for more information.", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index 262576ed8f..047a806e16 100644 --- a/includes/api/i18n/qqq.json +++ b/includes/api/i18n/qqq.json @@ -1263,8 +1263,6 @@ "apihelp-watch-example-unwatch": "{{doc-apihelp-example|watch}}", "apihelp-watch-example-generator": "{{doc-apihelp-example|watch}}", "apihelp-format-example-generic": "{{doc-apihelp-example|format|params=* $1 - Format name|paramstart=2|noseealso=1}}", - "apihelp-dbg-description": "{{doc-apihelp-description|dbg|seealso=* {{msg-mw|apihelp-dbgfm-description}}}}", - "apihelp-dbgfm-description": "{{doc-apihelp-description|dbgfm|seealso=* {{msg-mw|apihelp-dbg-description}}}}", "apihelp-json-description": "{{doc-apihelp-description|json|seealso=* {{msg-mw|apihelp-jsonfm-description}}}}", "apihelp-json-param-callback": "{{doc-apihelp-param|json|callback}}", "apihelp-json-param-utf8": "{{doc-apihelp-param|json|utf8}}", @@ -1276,14 +1274,10 @@ "apihelp-php-param-formatversion": "{{doc-apihelp-param|json|formatversion}}", "apihelp-phpfm-description": "{{doc-apihelp-description|phpfm|seealso=* {{msg-mw|apihelp-php-description}}}}", "apihelp-rawfm-description": "{{doc-apihelp-description|rawfm|seealso=* {{msg-mw|apihelp-raw-description}}}}", - "apihelp-txt-description": "{{doc-apihelp-description|txt|seealso=* {{msg-mw|apihelp-txtfm-description}}}}", - "apihelp-txtfm-description": "{{doc-apihelp-description|txtfm|seealso=* {{msg-mw|apihelp-txt-description}}}}", "apihelp-xml-description": "{{doc-apihelp-description|xml|seealso=* {{msg-mw|apihelp-xmlfm-description}}}}", "apihelp-xml-param-xslt": "{{doc-apihelp-param|xml|xslt}}", "apihelp-xml-param-includexmlnamespace": "{{doc-apihelp-param|xml|includexmlnamespace}}", "apihelp-xmlfm-description": "{{doc-apihelp-description|xmlfm|seealso=* {{msg-mw|apihelp-xml-description}}}}", - "apihelp-yaml-description": "{{doc-apihelp-description|yaml|seealso=* {{msg-mw|apihelp-yamlfm-description}}}}", - "apihelp-yamlfm-description": "{{doc-apihelp-description|yamlfm|seealso=* {{msg-mw|apihelp-yaml-description}}}}", "api-format-title": "{{technical}}\nPage title when API output is pretty-printed in HTML.", "api-format-prettyprint-header": "{{technical}} Displayed as a header when API output is pretty-printed in HTML.\n\nParameters:\n* $1 - Format name\n* $2 - Non-pretty-printing module name", "api-format-prettyprint-header-only-html": "{{technical}} Displayed as a header when API output is pretty-printed in HTML, but there is no non-html module.\n\nParameters:\n* $1 - Format name", diff --git a/tests/phpunit/includes/api/format/ApiFormatDbgTest.php b/tests/phpunit/includes/api/format/ApiFormatDbgTest.php deleted file mode 100644 index addd16a6b2..0000000000 --- a/tests/phpunit/includes/api/format/ApiFormatDbgTest.php +++ /dev/null @@ -1,92 +0,0 @@ - \n array (\n 'dbg' => \n array (\n" . - " '*' => 'format=dbg has been deprecated. Please use format=json instead.',\n" . - " ),\n ),"; - - return array( - // Basic types - array( array( null ), "array ({$warning}\n 0 => NULL,\n)" ), - array( array( true ), "array ({$warning}\n 0 => '',\n)" ), - array( array( false ), "array ({$warning}\n)" ), - array( array( true, ApiResult::META_BC_BOOLS => array( 0 ) ), - "array ({$warning}\n 0 => true,\n)" ), - array( array( false, ApiResult::META_BC_BOOLS => array( 0 ) ), - "array ({$warning}\n 0 => false,\n)" ), - array( array( 42 ), "array ({$warning}\n 0 => 42,\n)" ), - array( array( 42.5 ), "array ({$warning}\n 0 => 42.5,\n)" ), - array( array( 1e42 ), "array ({$warning}\n 0 => 1.0E+42,\n)" ), - array( array( 'foo' ), "array ({$warning}\n 0 => 'foo',\n)" ), - array( array( 'fóo' ), "array ({$warning}\n 0 => 'fóo',\n)" ), - - // Arrays and objects - array( - array( array() ), - "array ({$warning}\n 0 => \n array (\n ),\n)" - ), - array( - array( array( 1 ) ), - "array ({$warning}\n 0 => \n array (\n 0 => 1,\n ),\n)" - ), - array( - array( array( 'x' => 1 ) ), - "array ({$warning}\n 0 => \n array (\n 'x' => 1,\n ),\n)" - ), - array( - array( array( 2 => 1 ) ), - "array ({$warning}\n 0 => \n array (\n 2 => 1,\n ),\n)" - ), - array( - array( (object)array() ), - "array ({$warning}\n 0 => \n array (\n ),\n)" - ), - array( - array( array( 1, ApiResult::META_TYPE => 'assoc' ) ), - "array ({$warning}\n 0 => \n array (\n 0 => 1,\n ),\n)" - ), - array( - array( array( 'x' => 1, ApiResult::META_TYPE => 'array' ) ), - "array ({$warning}\n 0 => \n array (\n 0 => 1,\n ),\n)" - ), - array( - array( array( 'x' => 1, ApiResult::META_TYPE => 'kvp' ) ), - "array ({$warning}\n 0 => \n array (\n 'x' => 1,\n ),\n)" - ), - array( - array( array( - 'x' => 1, - ApiResult::META_TYPE => 'BCkvp', - ApiResult::META_KVP_KEY_NAME => 'key' - ) ), - "array ({$warning}\n 0 => \n array (\n 0 => \n " . - "array (\n 'key' => 'x',\n '*' => 1,\n ),\n ),\n)" - ), - array( - array( array( 'x' => 1, ApiResult::META_TYPE => 'BCarray' ) ), - "array ({$warning}\n 0 => \n array (\n 'x' => 1,\n ),\n)" - ), - array( - array( array( 'a', 'b', ApiResult::META_TYPE => 'BCassoc' ) ), - "array ({$warning}\n 0 => \n array (\n 0 => 'a',\n 1 => 'b',\n ),\n)" - ), - - // Content - array( array( 'content' => 'foo', ApiResult::META_CONTENT => 'content' ), - "array ({$warning}\n '*' => 'foo',\n)" ), - - // BC Subelements - array( array( 'foo' => 'foo', ApiResult::META_BC_SUBELEMENTS => array( 'foo' ) ), - "array ({$warning}\n 'foo' => \n array (\n '*' => 'foo',\n ),\n)" ), - ); - } - -} diff --git a/tests/phpunit/includes/api/format/ApiFormatTxtTest.php b/tests/phpunit/includes/api/format/ApiFormatTxtTest.php deleted file mode 100644 index c779a3c0d1..0000000000 --- a/tests/phpunit/includes/api/format/ApiFormatTxtTest.php +++ /dev/null @@ -1,57 +0,0 @@ - Array\n (\n [txt] => Array\n (\n" . - " [*] => format=txt has been deprecated. Please use format=json instead.\n" . - " )\n\n )\n"; - - return array( - // Basic types - array( array( null ), "Array\n({$warning}\n [0] => \n)\n" ), - array( array( true ), "Array\n({$warning}\n [0] => \n)\n" ), - array( array( false ), "Array\n({$warning}\n)\n" ), - array( array( true, ApiResult::META_BC_BOOLS => array( 0 ) ), - "Array\n({$warning}\n [0] => 1\n)\n" ), - array( array( false, ApiResult::META_BC_BOOLS => array( 0 ) ), - "Array\n({$warning}\n [0] => \n)\n" ), - array( array( 42 ), "Array\n({$warning}\n [0] => 42\n)\n" ), - array( array( 42.5 ), "Array\n({$warning}\n [0] => 42.5\n)\n" ), - array( array( 1e42 ), "Array\n({$warning}\n [0] => 1.0E+42\n)\n" ), - array( array( 'foo' ), "Array\n({$warning}\n [0] => foo\n)\n" ), - array( array( 'fóo' ), "Array\n({$warning}\n [0] => fóo\n)\n" ), - - // Arrays and objects - array( array( array() ), "Array\n({$warning}\n [0] => Array\n (\n )\n\n)\n" ), - array( array( array( 1 ) ), "Array\n({$warning}\n [0] => Array\n (\n [0] => 1\n )\n\n)\n" ), - array( array( array( 'x' => 1 ) ), "Array\n({$warning}\n [0] => Array\n (\n [x] => 1\n )\n\n)\n" ), - array( array( array( 2 => 1 ) ), "Array\n({$warning}\n [0] => Array\n (\n [2] => 1\n )\n\n)\n" ), - array( array( (object)array() ), "Array\n({$warning}\n [0] => Array\n (\n )\n\n)\n" ), - array( array( array( 1, ApiResult::META_TYPE => 'assoc' ) ), "Array\n({$warning}\n [0] => Array\n (\n [0] => 1\n )\n\n)\n" ), - array( array( array( 'x' => 1, ApiResult::META_TYPE => 'array' ) ), "Array\n({$warning}\n [0] => Array\n (\n [0] => 1\n )\n\n)\n" ), - array( array( array( 'x' => 1, ApiResult::META_TYPE => 'kvp' ) ), "Array\n({$warning}\n [0] => Array\n (\n [x] => 1\n )\n\n)\n" ), - array( array( array( 'x' => 1, ApiResult::META_TYPE => 'BCkvp', ApiResult::META_KVP_KEY_NAME => 'key' ) ), - "Array\n({$warning}\n [0] => Array\n (\n [0] => Array\n (\n [key] => x\n [*] => 1\n )\n\n )\n\n)\n" ), - array( array( array( 'x' => 1, ApiResult::META_TYPE => 'BCarray' ) ), "Array\n({$warning}\n [0] => Array\n (\n [x] => 1\n )\n\n)\n" ), - array( array( array( 'a', 'b', ApiResult::META_TYPE => 'BCassoc' ) ), "Array\n({$warning}\n [0] => Array\n (\n [0] => a\n [1] => b\n )\n\n)\n" ), - - // Content - array( array( 'content' => 'foo', ApiResult::META_CONTENT => 'content' ), - "Array\n({$warning}\n [*] => foo\n)\n" ), - - // BC Subelements - array( array( 'foo' => 'foo', ApiResult::META_BC_SUBELEMENTS => array( 'foo' ) ), - "Array\n({$warning}\n [foo] => Array\n (\n [*] => foo\n )\n\n)\n" ), - ); - // @codingStandardsIgnoreEnd - } - -} -- 2.20.1