Last modified: 2010-05-15 15:38:23 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 T4334, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 2334 - Patch for missing (array) in line 1099 of GlobalFunctions.php
Patch for missing (array) in line 1099 of GlobalFunctions.php
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.5.x
Other Linux
: Normal normal with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
http://www.higginsandmacfarlane.net
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-06-05 14:15 UTC by Graham Higgins
Modified: 2010-05-15 15:38 UTC (History)
0 users

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


Attachments
patch for GlobalFunctions (616 bytes, patch)
2005-06-05 14:18 UTC, Graham Higgins
Details

Description Graham Higgins 2005-06-05 14:15:17 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.
Comment 1 Brion Vibber 2005-06-05 14:17:12 UTC
Fix is in the wrong place; the incorrect call should be fixed.
Comment 2 Graham Higgins 2005-06-05 14:18:44 UTC
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.
Comment 3 Graham Higgins 2005-06-05 14:27:09 UTC
(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.
Comment 4 Brion Vibber 2005-06-05 14:32:12 UTC
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.
Comment 5 Brion Vibber 2005-06-05 14:34:03 UTC
BTW, test.leuksman.com is logging errors internally, not displaying them.
Comment 6 Brion Vibber 2005-06-06 01:10:35 UTC
Added explicit check for null.

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


Navigation
Links