Last modified: 2011-03-13 18:04:57 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 5312 - wfElement function returns unclosed non-empty tag with null contents
wfElement function returns unclosed non-empty tag with null contents
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
PC All
: Lowest normal (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
  Show dependency treegraph
Reported: 2006-03-21 23:25 UTC by Rob Lanphier (RobLa)
Modified: 2011-03-13 18:04 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description Rob Lanphier (RobLa) 2006-03-21 23:25:59 UTC
wfElement has the following declaration:
function wfElement( $element, $attribs = null, $contents = '') 

Calling it with the following:
wfElement( "foo", null, null) 

...results in:

...instead of:

Patch is simply the following:

Index: GlobalFunctions.php
--- GlobalFunctions.php (MediaWiki 1.5.7)
+++ GlobalFunctions.php (working copy)
@@ -1184,7 +1184,7 @@
        if( is_null( $contents ) ) {
-               $out .= '>';
+               $out .= '/>';
        } else {
                if( $contents == '' ) {
                        $out .= ' />';
Comment 1 Brion Vibber 2006-03-21 23:36:17 UTC
That's by design so you can create open elements with all the bits.

However it might be better to split that to the separate wfOpenElement;
I've seen several mistakes where normally-string data that may end up
being null due to load errors ends up producing bad XML output.

Check for usage to see where explicit use of null might be used and needs
to be replaced before changing the function behavior.
Comment 2 Rob Lanphier (RobLa) 2006-03-21 23:47:13 UTC
ah, I see where I missed the documentation for the function.  I can imagine my
"fix" would break a lot of stuff, not just in the core code but also in any
extensions that might rely on this.

As sloppy as it might be from an API perspective, it might be better to create a
"null safe" version of wfElement, and deprecate wfElement.  However, in my case,
I'll just RTFM.  Don't keep this bug open on my account.
Comment 3 Antoine "hashar" Musso (WMF) 2007-05-10 20:56:01 UTC
I made a small change with r22083 that would help solve the issue.

I have found only one occurrence of Xml::element being called with
null content to actually open an element (in HTMLForm.php).

We can now probably recode Xml::element() to handle the 'null' content
as an empty string and always close the element.
Comment 4 Alex Z. 2009-07-21 04:20:52 UTC
wfElement and everything else in XmlFunctions has been marked as deprecated since December 2008.

Note You need to log in before you can comment on or make changes to this bug.