[geeklog-devel] Site breaks when there is one or more upcoming event?

Blank, Jessica Jessica.Blank at mtvnmix.com
Wed Mar 5 22:31:28 EST 2008

We have PHP 4.3.9... and your test script worked. However, my copy of Geeklog does not...

What I did to attempt to resolve the issue was to use var_dump() to dump what '$attr' actually is.

It dumps as 'array(0) { }'.

HOWEVER... and bizarrely... if I put the following line at the top of the function:

if (count($attr) < 1) { $attr = array(); }

...then it works fine. (Incidentally, as you would expect, var_dump() still dumps $attr precisely the same way.)

In other words:

foreach() doesn't work on an empty array if said array was created in the function declaration itself, a la:
    function a($x, $y, $z = array()) {}

However, it DOES work on an empty array if it was created inside
the function itself, a la:
    $z = array();

I may have perhaps uncovered a rather obscure bug in PHP 4.3.9? However, if I've encountered this error, others will likely encounter it as well. Perhaps my line should be added to the CVS copy just in case others are running the same version of PHP as me...


-----Original Message-----
From: geeklog-devel-bounces at lists.geeklog.net on behalf of Joe Mucchiello
Sent: Wed 3/5/2008 8:14 PM
To: Geeklog Development
Subject: Re: [geeklog-devel] Site breaks when there is one or more upcoming event?
At 06:45 PM 3/5/2008, Blank, Jessica wrote:
>The code segment in question, located in the function 
>COM_createLink($content, $url, $attr = array()), is this:
>     foreach ($attr as $key => $value) {
>         $attr_str .= " $key=\"$value\"";
>     }
>As a 'band-aid' fix on the problem, to make the site viewable, I 
>wrapped these three lines of code in this:
>     if (count($attr) > 0) {
>     }

That works fine for me in PHP 5.2 and 4.4.7 in . What version of PHP 
are you running? This is my test app:


error_reporting( E_STRICT );
echo "hello<BR>";

function func($y = array())
     foreach ($y as $k => $v) {
         echo $k . ' => ' . $v . '<br>';

echo "goodbye<BR>";



Joe Mucchiello
Throwing Dice Games

geeklog-devel mailing list
geeklog-devel at lists.geeklog.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist8.pair.net/pipermail/geeklog-devel/attachments/20080305/f0b5a714/attachment.html>

More information about the geeklog-devel mailing list