DumpStringOutput: Rename getOutput() to __toString()
Though getOutput() is what first came to mind, I do not particularly like the name, partly because it is used in many, many places as a method that returns an OutputPage object. * Renamed the method to __toString(). This is appropriate because each instance, at any given time, corresponds to a single string value (and exceptions cannot occur during this conversion). * Removed unnecessary variables from ApiQuery and ExportTest. In these and most other cases, it should no longer be necessary to call getOutput() explicitly. Change-Id: Icf202743d1f332f8981338f42eb6e3e5a04abdf1
This commit is contained in:
parent
1a7bde454e
commit
be46ffa771
3 changed files with 4 additions and 6 deletions
|
|
@ -450,7 +450,6 @@ class ApiQuery extends ApiBase {
|
|||
$exporter->pageByTitle( $title );
|
||||
}
|
||||
$exporter->closeStream();
|
||||
$exportxml = $sink->getOutput();
|
||||
|
||||
// Don't check the size of exported stuff
|
||||
// It's not continuable, so it would cause more
|
||||
|
|
@ -458,10 +457,10 @@ class ApiQuery extends ApiBase {
|
|||
if ( $this->mParams['exportnowrap'] ) {
|
||||
$result->reset();
|
||||
// Raw formatter will handle this
|
||||
$result->addValue( null, 'text', $exportxml, ApiResult::NO_SIZE_CHECK );
|
||||
$result->addValue( null, 'text', $sink, ApiResult::NO_SIZE_CHECK );
|
||||
$result->addValue( null, 'mime', 'text/xml', ApiResult::NO_SIZE_CHECK );
|
||||
} else {
|
||||
$result->addValue( 'query', 'export', $exportxml, ApiResult::NO_SIZE_CHECK );
|
||||
$result->addValue( 'query', 'export', $sink, ApiResult::NO_SIZE_CHECK );
|
||||
$result->addValue( 'query', ApiResult::META_BC_SUBELEMENTS, [ 'export' ] );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class DumpStringOutput extends DumpOutput {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOutput() {
|
||||
public function __toString() {
|
||||
return $this->output;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,10 +35,9 @@ class ExportTest extends MediaWikiLangTestCase {
|
|||
$exporter->openStream();
|
||||
$exporter->pageByTitle( $title );
|
||||
$exporter->closeStream();
|
||||
$xmlString = $sink->getOutput();
|
||||
|
||||
// This throws error if invalid xml output
|
||||
$xmlObject = simplexml_load_string( $xmlString );
|
||||
$xmlObject = simplexml_load_string( $sink );
|
||||
|
||||
/**
|
||||
* Check namespaces match xml
|
||||
|
|
|
|||
Loading…
Reference in a new issue