* New-style continuation is now the default for API action=continue. Clients may
use the 'rawcontinue' parameter to receive raw query-continue data, but the
new style is encouraged as it's harder to implement incorrectly.
+* Deprecated API formats dump and wddx have been completely removed.
=== New features in 1.26 ===
* (T51506) Now action=info gives estimates of actual watchers for a page.
* New-style continuation is now the default for action=continue. Clients may
use the 'rawcontinue' parameter to receive raw query-continue data, but the
new style is encouraged as it's harder to implement incorrectly.
+* Deprecated API formats dump and wddx have been completely removed.
* API action=query&list=tags: The displayname can now be boolean false if the
tag is meant to be hidden from user interfaces.
* action=import no longer allows both the namespace= and rootpage= parameters
'ApiFileRevert' => __DIR__ . '/includes/api/ApiFileRevert.php',
'ApiFormatBase' => __DIR__ . '/includes/api/ApiFormatBase.php',
'ApiFormatDbg' => __DIR__ . '/includes/api/ApiFormatDbg.php',
- 'ApiFormatDump' => __DIR__ . '/includes/api/ApiFormatDump.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',
- 'ApiFormatWddx' => __DIR__ . '/includes/api/ApiFormatWddx.php',
'ApiFormatXml' => __DIR__ . '/includes/api/ApiFormatXml.php',
'ApiFormatXmlRsd' => __DIR__ . '/includes/api/ApiRsd.php',
'ApiFormatYaml' => __DIR__ . '/includes/api/ApiFormatYaml.php',
}
/**
- * To avoid code duplication with the deprecation of dbg, dump, txt, wddx,
+ * 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.
*/
// Escape everything first for full coverage
$text = htmlspecialchars( $text );
- if ( $this->mFormat === 'XML' || $this->mFormat === 'WDDX' ) {
+ if ( $this->mFormat === 'XML' ) {
// encode all comments or tags as safe blue strings
$text = str_replace( '<', '<span style="color:blue;"><', $text );
$text = str_replace( '>', '></span>', $text );
+++ /dev/null
-<?php
-/**
- *
- *
- * Created on August 8, 2010
- *
- * Copyright © 2010 Soxred93
- *
- * 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_dump() output formatter
- * @deprecated since 1.24
- * @ingroup API
- */
-class ApiFormatDump 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',
- ) );
- ob_start();
- var_dump( $data );
- $result = ob_get_contents();
- ob_end_clean();
- $this->printText( $result );
- }
-
- public function isDeprecated() {
- return true;
- }
-}
+++ /dev/null
-<?php
-/**
- *
- *
- * Created on Oct 22, 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 WDDX output formatter
- * @deprecated since 1.24
- * @ingroup API
- */
-class ApiFormatWddx extends ApiFormatBase {
-
- public function getMimeType() {
- return 'text/xml';
- }
-
- public function execute() {
- $this->markDeprecated();
-
- $data = $this->getResult()->getResultData( null, array(
- 'BC' => array(),
- 'Types' => array( 'AssocAsObject' => true ),
- 'Strip' => 'all',
- ) );
-
- if ( !$this->getIsHtml() && !static::useSlowPrinter() ) {
- $txt = wddx_serialize_value( $data );
- $txt = str_replace(
- '<struct><var name=\'php_class_name\'><string>stdClass</string></var>',
- '<struct>',
- $txt
- );
- $this->printText( $txt );
- } else {
- // Don't do newlines and indentation if we weren't asked
- // for pretty output
- $nl = ( $this->getIsHtml() ? "\n" : '' );
- $indstr = ( $this->getIsHtml() ? ' ' : '' );
- $this->printText( "<?xml version=\"1.0\"?>$nl" );
- $this->printText( "<wddxPacket version=\"1.0\">$nl" );
- $this->printText( "$indstr<header />$nl" );
- $this->printText( "$indstr<data>$nl" );
- $this->slowWddxPrinter( $data, 4 );
- $this->printText( "$indstr</data>$nl" );
- $this->printText( "</wddxPacket>$nl" );
- }
- }
-
- public static function useSlowPrinter() {
- if ( !function_exists( 'wddx_serialize_value' ) ) {
- return true;
- }
-
- // Some versions of PHP have a broken wddx_serialize_value, see
- // PHP bug 45314. Test encoding an affected character (U+00A0)
- // to avoid this.
- $expected =
- "<wddxPacket version='1.0'><header/><data><string>\xc2\xa0</string></data></wddxPacket>";
- if ( wddx_serialize_value( "\xc2\xa0" ) !== $expected ) {
- return true;
- }
-
- // Some versions of HHVM don't correctly encode ampersands.
- $expected =
- "<wddxPacket version='1.0'><header/><data><string>&</string></data></wddxPacket>";
- if ( wddx_serialize_value( '&' ) !== $expected ) {
- return true;
- }
-
- // Some versions of HHVM don't correctly encode empty arrays as subvalues.
- $expected =
- "<wddxPacket version='1.0'><header/><data><array length='1'><array length='0'></array></array></data></wddxPacket>";
- if ( wddx_serialize_value( array( array() ) ) !== $expected ) {
- return true;
- }
-
- // Some versions of HHVM don't correctly encode associative arrays with numeric keys.
- $expected =
- "<wddxPacket version='1.0'><header/><data><struct><var name='2'><number>1</number></var></struct></data></wddxPacket>";
- if ( wddx_serialize_value( array( 2 => 1 ) ) !== $expected ) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Recursively go through the object and output its data in WDDX format.
- * @param mixed $elemValue
- * @param int $indent
- */
- function slowWddxPrinter( $elemValue, $indent = 0 ) {
- $indstr = ( $this->getIsHtml() ? str_repeat( ' ', $indent ) : '' );
- $indstr2 = ( $this->getIsHtml() ? str_repeat( ' ', $indent + 2 ) : '' );
- $nl = ( $this->getIsHtml() ? "\n" : '' );
-
- if ( is_array( $elemValue ) ) {
- $cnt = count( $elemValue );
- if ( $cnt != 0 && array_keys( $elemValue ) !== range( 0, $cnt - 1 ) ) {
- $elemValue = (object)$elemValue;
- }
- }
-
- if ( is_array( $elemValue ) ) {
- // Regular array
- $this->printText( $indstr . Xml::element( 'array', array(
- 'length' => count( $elemValue ) ), null ) . $nl );
- foreach ( $elemValue as $subElemValue ) {
- $this->slowWddxPrinter( $subElemValue, $indent + 2 );
- }
- $this->printText( "$indstr</array>$nl" );
- } elseif ( is_object( $elemValue ) ) {
- // Associative array (<struct>)
- $this->printText( "$indstr<struct>$nl" );
- foreach ( $elemValue as $subElemName => $subElemValue ) {
- $this->printText( $indstr2 . Xml::element( 'var', array(
- 'name' => $subElemName
- ), null ) . $nl );
- $this->slowWddxPrinter( $subElemValue, $indent + 4 );
- $this->printText( "$indstr2</var>$nl" );
- }
- $this->printText( "$indstr</struct>$nl" );
- } elseif ( is_int( $elemValue ) || is_float( $elemValue ) ) {
- $this->printText( $indstr . Xml::element( 'number', null, $elemValue ) . $nl );
- } elseif ( is_string( $elemValue ) ) {
- $this->printText( $indstr . Xml::element( 'string', null, $elemValue, false ) . $nl );
- } elseif ( is_bool( $elemValue ) ) {
- $this->printText( $indstr . Xml::element( 'boolean',
- array( 'value' => $elemValue ? 'true' : 'false' ) ) . $nl
- );
- } elseif ( $elemValue === null ) {
- $this->printText( $indstr . Xml::element( 'null', array() ) . $nl );
- } else {
- ApiBase::dieDebug( __METHOD__, 'Unknown type ' . gettype( $elemValue ) );
- }
- }
-
- public function isDeprecated() {
- return true;
- }
-}
'jsonfm' => 'ApiFormatJson',
'php' => 'ApiFormatPhp',
'phpfm' => 'ApiFormatPhp',
- 'wddx' => 'ApiFormatWddx',
- 'wddxfm' => 'ApiFormatWddx',
'xml' => 'ApiFormatXml',
'xmlfm' => 'ApiFormatXml',
'yaml' => 'ApiFormatYaml',
'txtfm' => 'ApiFormatTxt',
'dbg' => 'ApiFormatDbg',
'dbgfm' => 'ApiFormatDbg',
- 'dump' => 'ApiFormatDump',
- 'dumpfm' => 'ApiFormatDump',
'none' => 'ApiFormatNone',
);
$result_array[ApiResult::META_BC_SUBELEMENTS][] = 'limitreporthtml';
}
- if ( $params['generatexml'] ) {
+ if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) {
+ if ( !isset( $prop['parsetree'] ) ) {
+ $this->logFeatureUsage( 'action=parse&generatexml' );
+ }
if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) {
- $this->dieUsage( "generatexml is only supported for wikitext content", "notwikitext" );
+ $this->dieUsage( "parsetree is only supported for wikitext content", "notwikitext" );
}
$wgParser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS );
'properties',
'limitreportdata',
'limitreporthtml',
+ 'parsetree',
+ ),
+ ApiBase::PARAM_HELP_MSG_PER_VALUE => array(
+ 'parsetree' => array( 'apihelp-parse-paramvalue-prop-parsetree', CONTENT_MODEL_WIKITEXT ),
),
- ApiBase::PARAM_HELP_MSG_PER_VALUE => array(),
),
'pst' => false,
'onlypst' => false,
ApiBase::PARAM_HELP_MSG => array(
'apihelp-parse-param-generatexml', CONTENT_MODEL_WIKITEXT
),
+ ApiBase::PARAM_DEPRECATED => true,
),
'preview' => false,
'sectionpreview' => false,
protected $fld_ids = false, $fld_flags = false, $fld_timestamp = false,
$fld_size = false, $fld_sha1 = false, $fld_comment = false,
$fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
- $fld_content = false, $fld_tags = false, $fld_contentmodel = false;
+ $fld_content = false, $fld_tags = false, $fld_contentmodel = false, $fld_parsetree = false;
public function execute() {
$this->run();
$this->fld_userid = isset( $prop['userid'] );
$this->fld_user = isset( $prop['user'] );
$this->fld_tags = isset( $prop['tags'] );
+ $this->fld_parsetree = isset( $prop['parsetree'] );
if ( !empty( $params['contentformat'] ) ) {
$this->contentFormat = $params['contentformat'];
$this->limit = $params['limit'];
$this->fetchContent = $this->fld_content || !is_null( $this->diffto )
- || !is_null( $this->difftotext );
+ || !is_null( $this->difftotext ) || $this->fld_parsetree;
$smallLimit = false;
if ( $this->fetchContent ) {
$vals['textmissing'] = true;
}
}
- if ( $this->fld_content && $content ) {
- $text = null;
-
- if ( $this->generateXML ) {
+ if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
+ if ( !$this->fld_parsetree ) {
+ $this->logFeatureUsage( 'action=query&prop=revisions+base&generatexml' );
+ }
+ if ( $content ) {
if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
$t = $content->getNativeData(); # note: don't set $text
" uses content model " . $content->getModel() );
}
}
+ }
+
+ if ( $this->fld_content && $content ) {
+ $text = null;
if ( $this->expandTemplates && !$this->parseContent ) {
#XXX: implement template expansion for all content types in ContentHandler?
'comment',
'parsedcomment',
'content',
- 'tags'
+ 'tags',
+ 'parsetree',
),
ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-prop',
),
),
'generatexml' => array(
ApiBase::PARAM_DFLT => false,
+ ApiBase::PARAM_DEPRECATED => true,
ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-generatexml',
),
'parse' => array(
"apihelp-parse-paramvalue-prop-properties": "Gives various properties defined in the parsed wikitext.",
"apihelp-parse-paramvalue-prop-limitreportdata": "Gives the limit report in a structured way. Gives no data, when <var>$1disablepp</var> is set.",
"apihelp-parse-paramvalue-prop-limitreporthtml": "Gives the HTML version of the limit report. Gives no data, when <var>$1disablepp</var> is set.",
+ "apihelp-parse-paramvalue-prop-parsetree": "The XML parse tree of revision content (requires content model <code>$1</code>)",
"apihelp-parse-param-pst": "Do a pre-save transform on the input before parsing it. Only valid when used with text.",
"apihelp-parse-param-onlypst": "Do a pre-save transform (PST) on the input, but don't parse it. Returns the same wikitext, after a PST has been applied. Only valid when used with <var>$1text</var>.",
"apihelp-parse-param-effectivelanglinks": "Includes language links supplied by extensions (for use with <kbd>$1prop=langlinks</kbd>).",
"apihelp-parse-param-sectiontitle": "New section title when <var>section</var> is <kbd>new</kbd>.\n\nUnlike page editing, this does not fall back to <var>summary</var> when omitted or empty.",
"apihelp-parse-param-disablepp": "Disable the PP Report from the parser output.",
"apihelp-parse-param-disableeditsection": "Disable edit section links from the parser output.",
- "apihelp-parse-param-generatexml": "Generate XML parse tree (requires content model <code>$1</code>).",
+ "apihelp-parse-param-generatexml": "Generate XML parse tree (requires content model <code>$1</code>; replaced by <kbd>$2prop=parsetree</kbd>).",
"apihelp-parse-param-preview": "Parse in preview mode.",
"apihelp-parse-param-sectionpreview": "Parse in section preview mode (enables preview mode too).",
"apihelp-parse-param-disabletoc": "Disable table of contents in output.",
"apihelp-query+revisions-example-first5-after": "Get first 5 revisions of the <kbd>Main Page</kbd> made after 2006-05-01.",
"apihelp-query+revisions-example-first5-not-localhost": "Get first 5 revisions of the <kbd>Main Page</kbd> that were not made by anonymous user <kbd>127.0.0.1</kbd>.",
"apihelp-query+revisions-example-first5-user": "Get first 5 revisions of the <kbd>Main Page</kbd> that were made by the user <kbd>MediaWiki default</kbd>.",
- "apihelp-query+revisions+base-param-prop": "Which properties to get for each revision:\n;ids:The ID of the revision.\n;flags:Revision flags (minor).\n;timestamp:The timestamp of the revision.\n;user:User that made the revision.\n;userid:User ID of the revision creator.\n;size:Length (bytes) of the revision.\n;sha1:SHA-1 (base 16) of the revision.\n;contentmodel:Content model ID of the revision.\n;comment:Comment by the user for the revision.\n;parsedcomment:Parsed comment by the user for the revision.\n;content:Text of the revision.\n;tags:Tags for the revision.",
+ "apihelp-query+revisions+base-param-prop": "Which properties to get for each revision:\n;ids:The ID of the revision.\n;flags:Revision flags (minor).\n;timestamp:The timestamp of the revision.\n;user:User that made the revision.\n;userid:User ID of the revision creator.\n;size:Length (bytes) of the revision.\n;sha1:SHA-1 (base 16) of the revision.\n;contentmodel:Content model ID of the revision.\n;comment:Comment by the user for the revision.\n;parsedcomment:Parsed comment by the user for the revision.\n;content:Text of the revision.\n;tags:Tags for the revision.\n;parsetree:The XML parse tree of revision content.",
"apihelp-query+revisions+base-param-limit": "Limit how many revisions will be returned.",
"apihelp-query+revisions+base-param-expandtemplates": "Expand templates in revision content (requires $1prop=content).",
- "apihelp-query+revisions+base-param-generatexml": "Generate XML parse tree for revision content (requires $1prop=content).",
+ "apihelp-query+revisions+base-param-generatexml": "Generate XML parse tree for revision content (requires $1prop=content; replaced by <kbd>$1prop=parsetree</kbd>).",
"apihelp-query+revisions+base-param-parse": "Parse revision content (requires $1prop=content). For performance reasons, if this option is used, $1limit is enforced to 1.",
"apihelp-query+revisions+base-param-section": "Only retrieve the content of this section number.",
"apihelp-query+revisions+base-param-diffto": "Revision ID to diff each revision to. Use <kbd>prev</kbd>, <kbd>next</kbd> and <kbd>cur</kbd> for the previous, next and current revision respectively.",
"apihelp-format-example-generic": "Format 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-dump-description": "Output data in PHP's <code>var_dump()</code> format.",
- "apihelp-dumpfm-description": "Output data in PHP's <code>var_dump()</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>.",
"apihelp-rawfm-description": "Output data with the 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-wddx-description": "Output data in WDDX format.",
- "apihelp-wddxfm-description": "Output data in WDDX 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-parse-paramvalue-prop-properties": "{{doc-apihelp-paramvalue|parse|prop|properties}}",
"apihelp-parse-paramvalue-prop-limitreportdata": "{{doc-apihelp-paramvalue|parse|prop|limitreportdata}}",
"apihelp-parse-paramvalue-prop-limitreporthtml": "{{doc-apihelp-paramvalue|parse|prop|limitreporthtml}}",
+ "apihelp-parse-paramvalue-prop-parsetree": "{{doc-apihelp-paramvalue|parse|prop|parsetree|params=* $1 - Value of the constant CONTENT_MODEL_WIKITEXT|paramstart=2}}",
"apihelp-parse-param-pst": "{{doc-apihelp-param|parse|pst}}",
"apihelp-parse-param-onlypst": "{{doc-apihelp-param|parse|onlypst}}",
"apihelp-parse-param-effectivelanglinks": "{{doc-apihelp-param|parse|effectivelanglinks}}",
"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-dump-description": "{{doc-apihelp-description|dump|seealso=* {{msg-mw|apihelp-dumpfm-description}}}}",
- "apihelp-dumpfm-description": "{{doc-apihelp-description|dumpfm|seealso=* {{msg-mw|apihelp-dump-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}}",
"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-wddx-description": "{{doc-apihelp-description|wddx|seealso=* {{msg-mw|apihelp-wddxfm-description}}}}",
- "apihelp-wddxfm-description": "{{doc-apihelp-description|wddxfm|seealso=* {{msg-mw|apihelp-wddx-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}}",
+++ /dev/null
-<?php
-
-/**
- * @group API
- * @covers ApiFormatDump
- */
-class ApiFormatDumpTest extends ApiFormatTestBase {
-
- protected $printerName = 'dump';
-
- public static function provideGeneralEncoding() {
- // Sigh. Docs claim it's a boolean, but can have values 0, 1, or 2.
- // Fortunately wfIniGetBool does the right thing.
- if ( wfIniGetBool( 'xdebug.overload_var_dump' ) ) {
- return array(
- array( array(), 'Cannot test ApiFormatDump when xDebug overloads var_dump', array( 'SKIP' => true ) ),
- );
- }
-
- $warning = "\n [\"warnings\"]=>\n array(1) {\n [\"dump\"]=>\n array(1) {\n [\"*\"]=>\n" .
- " string(64) \"format=dump has been deprecated. Please use format=json instead.\"\n" .
- " }\n }";
-
- return array(
- // Basic types
- array( array( null ), "array(2) {{$warning}\n [0]=>\n NULL\n}\n" ),
- array( array( true ), "array(2) {{$warning}\n [0]=>\n string(0) \"\"\n}\n" ),
- array( array( false ), "array(1) {{$warning}\n}\n" ),
- array( array( true, ApiResult::META_BC_BOOLS => array( 0 ) ),
- "array(2) {{$warning}\n [0]=>\n bool(true)\n}\n" ),
- array( array( false, ApiResult::META_BC_BOOLS => array( 0 ) ),
- "array(2) {{$warning}\n [0]=>\n bool(false)\n}\n" ),
- array( array( 42 ), "array(2) {{$warning}\n [0]=>\n int(42)\n}\n" ),
- array( array( 42.5 ), "array(2) {{$warning}\n [0]=>\n float(42.5)\n}\n" ),
- array( array( 1e42 ), "array(2) {{$warning}\n [0]=>\n float(1.0E+42)\n}\n" ),
- array( array( 'foo' ), "array(2) {{$warning}\n [0]=>\n string(3) \"foo\"\n}\n" ),
- array( array( 'fóo' ), "array(2) {{$warning}\n [0]=>\n string(4) \"fóo\"\n}\n" ),
-
- // Arrays
- array( array( array() ), "array(2) {{$warning}\n [0]=>\n array(0) {\n }\n}\n" ),
- array( array( array( 1 ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n int(1)\n }\n}\n" ),
- array( array( array( 'x' => 1 ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [\"x\"]=>\n int(1)\n }\n}\n" ),
- array( array( array( 2 => 1 ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [2]=>\n int(1)\n }\n}\n" ),
- array( array( (object)array() ), "array(2) {{$warning}\n [0]=>\n array(0) {\n }\n}\n" ),
- array( array( array( 1, ApiResult::META_TYPE => 'assoc' ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n int(1)\n }\n}\n" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'array' ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n int(1)\n }\n}\n" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'kvp' ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [\"x\"]=>\n int(1)\n }\n}\n" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'BCkvp', ApiResult::META_KVP_KEY_NAME => 'key' ) ),
- "array(2) {{$warning}\n [0]=>\n array(1) {\n [0]=>\n array(2) {\n [\"key\"]=>\n string(1) \"x\"\n [\"*\"]=>\n int(1)\n }\n }\n}\n" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'BCarray' ) ), "array(2) {{$warning}\n [0]=>\n array(1) {\n [\"x\"]=>\n int(1)\n }\n}\n" ),
- array( array( array( 'a', 'b', ApiResult::META_TYPE => 'BCassoc' ) ), "array(2) {{$warning}\n [0]=>\n array(2) {\n [0]=>\n string(1) \"a\"\n [1]=>\n string(1) \"b\"\n }\n}\n" ),
-
- // Content
- array( array( 'content' => 'foo', ApiResult::META_CONTENT => 'content' ),
- "array(2) {{$warning}\n [\"*\"]=>\n string(3) \"foo\"\n}\n" ),
-
- // BC Subelements
- array( array( 'foo' => 'foo', ApiResult::META_BC_SUBELEMENTS => array( 'foo' ) ),
- "array(2) {{$warning}\n [\"foo\"]=>\n array(1) {\n [\"*\"]=>\n string(3) \"foo\"\n }\n}\n" ),
- );
- }
-
-}
+++ /dev/null
-<?php
-
-/**
- * @group API
- * @covers ApiFormatWddx
- */
-class ApiFormatWddxTest extends ApiFormatTestBase {
-
- protected $printerName = 'wddx';
-
- public static function provideGeneralEncoding() {
- if ( ApiFormatWddx::useSlowPrinter() ) {
- return array(
- array( array(), 'Fast Wddx printer is unavailable', array( 'SKIP' => true ) )
- );
- }
- return self::provideEncoding();
- }
-
- public static function provideEncoding() {
- $p = '<wddxPacket version=\'1.0\'><header/><data><struct><var name=\'warnings\'><struct><var name=\'wddx\'><struct><var name=\'*\'><string>format=wddx has been deprecated. Please use format=json instead.</string></var></struct></var></struct></var>';
- $s = '</struct></data></wddxPacket>';
-
- return array(
- // Basic types
- array( array( null ), "{$p}<var name='0'><null/></var>{$s}" ),
- array( array( true ), "{$p}<var name='0'><string></string></var>{$s}" ),
- array( array( false ), "{$p}{$s}" ),
- array( array( true, ApiResult::META_BC_BOOLS => array( 0 ) ),
- "{$p}<var name='0'><boolean value='true'/></var>{$s}" ),
- array( array( false, ApiResult::META_BC_BOOLS => array( 0 ) ),
- "{$p}<var name='0'><boolean value='false'/></var>{$s}" ),
- array( array( 42 ), "{$p}<var name='0'><number>42</number></var>{$s}" ),
- array( array( 42.5 ), "{$p}<var name='0'><number>42.5</number></var>{$s}" ),
- array( array( 1e42 ), "{$p}<var name='0'><number>1.0E+42</number></var>{$s}" ),
- array( array( 'foo' ), "{$p}<var name='0'><string>foo</string></var>{$s}" ),
- array( array( 'fóo' ), "{$p}<var name='0'><string>fóo</string></var>{$s}" ),
-
- // Arrays and objects
- array( array( array() ), "{$p}<var name='0'><array length='0'></array></var>{$s}" ),
- array( array( array( 1 ) ), "{$p}<var name='0'><array length='1'><number>1</number></array></var>{$s}" ),
- array( array( array( 'x' => 1 ) ), "{$p}<var name='0'><struct><var name='x'><number>1</number></var></struct></var>{$s}" ),
- array( array( array( 2 => 1 ) ), "{$p}<var name='0'><struct><var name='2'><number>1</number></var></struct></var>{$s}" ),
- array( array( (object)array() ), "{$p}<var name='0'><struct></struct></var>{$s}" ),
- array( array( array( 1, ApiResult::META_TYPE => 'assoc' ) ), "{$p}<var name='0'><struct><var name='0'><number>1</number></var></struct></var>{$s}" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'array' ) ), "{$p}<var name='0'><array length='1'><number>1</number></array></var>{$s}" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'kvp' ) ), "{$p}<var name='0'><struct><var name='x'><number>1</number></var></struct></var>{$s}" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'BCkvp', ApiResult::META_KVP_KEY_NAME => 'key' ) ),
- "{$p}<var name='0'><array length='1'><struct><var name='key'><string>x</string></var><var name='*'><number>1</number></var></struct></array></var>{$s}" ),
- array( array( array( 'x' => 1, ApiResult::META_TYPE => 'BCarray' ) ), "{$p}<var name='0'><struct><var name='x'><number>1</number></var></struct></var>{$s}" ),
- array( array( array( 'a', 'b', ApiResult::META_TYPE => 'BCassoc' ) ), "{$p}<var name='0'><array length='2'><string>a</string><string>b</string></array></var>{$s}" ),
-
- // Content
- array( array( 'content' => 'foo', ApiResult::META_CONTENT => 'content' ),
- "{$p}<var name='*'><string>foo</string></var>{$s}" ),
-
- // BC Subelements
- array( array( 'foo' => 'foo', ApiResult::META_BC_SUBELEMENTS => array( 'foo' ) ),
- "{$p}<var name='foo'><struct><var name='*'><string>foo</string></var></struct></var>{$s}" ),
- );
- }
-
- /**
- * @dataProvider provideEncoding
- */
- public function testSlowEncoding( array $data, $expect, array $params = array() ) {
- // Adjust expectation for differences between fast and slow printers.
- $expect = str_replace( '\'', '"', $expect );
- $expect = str_replace( '/>', ' />', $expect );
- $expect = '<?xml version="1.0"?>' . $expect;
-
- $this->assertSame( $expect, $this->encodeData( $params, $data, 'ApiFormatWddxTest_SlowWddx' ) );
- }
-}
-
-class ApiFormatWddxTest_SlowWddx extends ApiFormatWddx {
- public static function useSlowPrinter() {
- return true;
- }
-}