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
This commit is contained in:
Brad Jorsch 2015-11-12 12:58:46 -05:00
parent 636f3e9282
commit 42e257a1a2
11 changed files with 6 additions and 336 deletions

View file

@ -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 ===

View file

@ -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',

View file

@ -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
* @{

View file

@ -1,54 +0,0 @@
<?php
/**
*
*
* Created on Oct 22, 2006
*
* Copyright © 2008 Roan Kattouw "<Firstname>.<Lastname>@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;
}
}

View file

@ -1,54 +0,0 @@
<?php
/**
*
*
* Created on Oct 22, 2006
*
* Copyright © 2008 Roan Kattouw "<Firstname>.<Lastname>@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;
}
}

View file

@ -1,46 +0,0 @@
<?php
/**
*
*
* Created on Sep 19, 2006
*
* Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@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;
}
}

View file

@ -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',
);

View file

@ -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 <code>var_export()</code> format.",
"apihelp-dbgfm-description": "Output data in PHP's <code>var_export()</code> 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 <var>formatversion</var> is not <kbd>1</kbd>.",
@ -1371,14 +1369,10 @@
"apihelp-php-param-formatversion": "Output formatting:\n;1:Backwards-compatible format (XML-style booleans, <samp>*</samp> keys for content nodes, etc.).\n;2:Experimental modern format. Details may change!\n;latest:Use the latest format (currently <kbd>2</kbd>), 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 <code>print_r()</code> format.",
"apihelp-txtfm-description": "Output data in PHP's <code>print_r()</code> 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 <code>.xsl</code>.",
"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 <var>format</var> parameter to change the output format. To see the non-HTML representation of the $1 format, set <kbd>format=$2</kbd>.\n\nSee the [[mw:API|complete documentation]], or the [[Special:ApiHelp/main|API help]] for more information.",

View file

@ -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",

View file

@ -1,92 +0,0 @@
<?php
/**
* @group API
* @covers ApiFormatDbg
*/
class ApiFormatDbgTest extends ApiFormatTestBase {
protected $printerName = 'dbg';
public static function provideGeneralEncoding() {
$warning = "\n 'warnings' => \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)" ),
);
}
}

View file

@ -1,57 +0,0 @@
<?php
/**
* @group API
* @covers ApiFormatTxt
*/
class ApiFormatTxtTest extends ApiFormatTestBase {
protected $printerName = 'txt';
public static function provideGeneralEncoding() {
// @codingStandardsIgnoreStart Generic.Files.LineLength
$warning = "\n [warnings] => 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
}
}