From deaffd82628e96aa6a0762e893bf797c591b0413 Mon Sep 17 00:00:00 2001 From: Petr Onderka Date: Wed, 23 Jan 2013 21:55:39 +0100 Subject: [PATCH] Don't return invalid XML from paraminfo when one of parameter values is null The module setglobalaccountstatus currently has null as one of the values for one of its parameters, which causes paraminfo to return invalid XML (unclosed tag). I believe values shouldn't be null, but paraminfo shouldn't return invalid XML even when they are. This problem occured only with values that go into element content, those that are rendered as attributes were already fine. This change modifies ApiFormatXml, so it affects all modules. Change-Id: Ibf5c329e7bfa375b06f0976ebb9e449f2cb1c927 --- includes/api/ApiFormatXml.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index 582e405472..8dbeae497b 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -205,7 +205,13 @@ class ApiFormatXml extends ApiFormatBase { // ignore break; default: - $retval .= $indstr . Xml::element( $elemName, null, $elemValue ); + // to make sure null value doesn't produce unclosed element, + // which is what Xml::element( $elemName, null, null ) returns + if ( $elemValue === null ) { + $retval .= $indstr . Xml::element( $elemName ); + } else { + $retval .= $indstr . Xml::element( $elemName, null, $elemValue ); + } break; } return $retval; -- 2.20.1