From d115eafe622a39aa2351aa74473d63d9b59dbb19 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 6 Jun 2005 01:10:05 +0000 Subject: [PATCH] * (bug 2334) Accept null for attribs in wfElement without PHP warning --- RELEASE-NOTES | 1 + includes/GlobalFunctions.php | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 362c9e55e9..33368dea72 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 47646471b2..eb517f1f53 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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, -- 2.20.1