* (bug 2334) Accept null for attribs in wfElement without PHP warning
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 6 Jun 2005 01:10:05 +0000 (01:10 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 6 Jun 2005 01:10:05 +0000 (01:10 +0000)
RELEASE-NOTES
includes/GlobalFunctions.php

index 362c9e5..33368de 100644 (file)
@@ -268,6 +268,7 @@ Various bugfixes, small features, and a few experimental things:
 * (bug 2329) Fix title formatting in several special pages
 * (bug 2223) Add unique index on user_name field to prevent duplicate accounts
 * (bug 1976) fix shared user database with a table prefix set
+* (bug 2334) Accept null for attribs in wfElement without PHP warning
 
 
 === Caveats ===
index 4764647..eb517f1 100644 (file)
@@ -1094,10 +1094,12 @@ function wfGetSiteNotice() {
  * @param bool $contents NULL to make an open tag only; '' for a contentless closed tag (default)
  * @return string
  */
-function wfElement( $element, $attribs = array(), $contents = '') {
+function wfElement( $element, $attribs = null, $contents = '') {
        $out = '<' . $element;
-       foreach( $attribs as $name => $val ) {
-               $out .= ' ' . $name . '="' . htmlspecialchars( $val ) . '"';
+       if( !is_null( $attribs ) ) {
+               foreach( $attribs as $name => $val ) {
+                       $out .= ' ' . $name . '="' . htmlspecialchars( $val ) . '"';
+               }
        }
        if( is_null( $contents ) ) {
                $out .= '>';
@@ -1127,7 +1129,10 @@ function wfElementClean( $element, $attribs = array(), $contents = '') {
        if( $attribs ) {
                $attribs = array_map( array( 'UtfNormal', 'cleanUp' ), $attribs );
        }
-       return wfElement( $element, $attribs, UtfNormal::cleanUp( $contents ) );
+       if( $contents ) {
+               $contents = UtfNormal::cleanUp( $contents );
+       }
+       return wfElement( $element, $attribs, $contents );
 }
 
 /** Global singleton instance of MimeMagic. This is initialized on demand,