Page MenuHomePhabricator

Patch for missing (array) in line 1099 of GlobalFunctions.php
Closed, ResolvedPublic

Description

Author: gjh-mediazilla

Description:
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.


Version: 1.5.x
Severity: normal
OS: Linux
Platform: Other
URL: http://www.higginsandmacfarlane.net

Details

Reference
bz2334

Revisions and Commits

rARC Arcanist

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:31 PM
bzimport set Reference to bz2334.
bzimport added a subscriber: Unknown Object (MLST).

Fix is in the wrong place; the incorrect call should be fixed.

gjh-mediazilla wrote:

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.

Attached:

gjh-mediazilla wrote:

(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.

epriestley added a commit: Unknown Object (Diffusion Commit).Mar 4 2015, 8:15 AM
epriestley added a commit: Unknown Object (Diffusion Commit).
epriestley added a commit: Unknown Object (Diffusion Commit).
epriestley added a commit: Unknown Object (Diffusion Commit).
epriestley added a commit: Unknown Object (Diffusion Commit).
epriestley added a commit: Unknown Object (Diffusion Commit).
epriestley added a commit: Unknown Object (Diffusion Commit).
epriestley added a commit: Unknown Object (Diffusion Commit).
epriestley added a commit: Unknown Object (Diffusion Commit).
epriestley added a commit: Unknown Object (Diffusion Commit).
epriestley added a commit: Unknown Object (Diffusion Commit).