Last modified: 2010-05-15 15:38:23 UTC
Version page output: MediaWiki: 1.5alpha2 PHP: 5.0.3 (apache) MySQL: 4.0.18-Max PHP error seen: Invalid argument supplied for foreach() in mediawiki/includes/GlobalFunctions.php on line 1099 Answer found on: http://wordpress.org/support/topic/24530. (Array case inserted, error disappears.) Checked CVS, array cast missing from latest sources. Here's a diff if required. diff -uNr phase3/includes/GlobalFunctions.php wiki/includes/GlobalFunctions.php --- phase3/includes/GlobalFunctions.php 2005-06-01 07:17:42.000000000 +0100 +++ wiki/includes/GlobalFunctions.php 2005-06-05 14:40:20.000000000 +0100 @@ -1096,7 +1096,7 @@ */ function wfElement( $element, $attribs = array(), $contents = '') { $out = '<' . $element; - foreach( $attribs as $name => $val ) { + foreach( (array)$attribs as $name => $val ) { $out .= ' ' . $name . '="' . htmlspecialchars( $val ) . '"'; } if( is_null( $contents ) ) { HTH.
Fix is in the wrong place; the incorrect call should be fixed.
Created attachment 595 [details] patch for GlobalFunctions May be more convenient in this form - I'd have posted it as an attachment to the bug report rather than pasting it in the form field if I'd had the option but there didn't seem to be one.
(In reply to comment #1) > Fix is in the wrong place; the incorrect call should be fixed. > Sorry, just shows how much I don't know. I did look through a *lot* of unresolved posts on the net, quoting the same error. No-one seemed to have much of an answer other than the poster I references and there is an online 1.5alpha2 which isn't producing the same error (http://test.leuksman.com/index.php/Special:Export/Main_Page), so I was somewhat confused. I'm glad my copy's working again, though.
Well, posts on the net are probably just going to confirm that, yes, if you pass something that's not an array to foreach you get a warning. :) Either the function should be changed to explicitly accept null as an alternative to an array, or the uses of the function that pass null should be changed. Since null is shorter than array(), explicitly accepting null might be nice. I don't much like the cast, though; that would conceal actual errors such as passing a string or integer, probably in combination with screwing up the output.
BTW, test.leuksman.com is logging errors internally, not displaying them.
Added explicit check for null.