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

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T7312, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 5312 - wfElement function returns unclosed non-empty tag with null contents
wfElement function returns unclosed non-empty tag with null contents
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.5.x
PC All
: Lowest normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  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: ---


Attachments

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:
<foo>

...instead of:
<foo/>
...or
<foo></foo>

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.


Navigation
Links