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

Blank, Jessica Jessica.Blank at mtvnmix.com
Wed Mar 5 18:45:48 EST 2008


Well, this is frustrating.

In testing my dev system (which is a stock CVS download of Geeklog with only one .thtml file changed), I tried to test the 'Upcoming Events' block. I added an event for two days from now. The event went successfully into the system. However, when I went to the front page, I got:

==========================================================================
An error has occurred:
2 - Invalid argument supplied for foreach() @ /PATH/public_html/lib-common.php line 6082

array(5) {
  ["content"]=>
  string(10) "Test event"
  ["url"]=>
  string(69) "http://HOSTNAME/calendar/event.php?eid=20080305183132672""
  ["attr"]=>
  NULL
  ["retval"]=>
  string(0) ""
  ["attr_str"]=>
  string(76) "href="http://HOSTNAME/calendar/event.php?eid=20080305183132672"""
}

(This text is only displayed to users in the group 'Root')
==========================================================================

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) {
    }

This fixed my problem, naturally, but it's a kluge. Why is this code segment messing up in the first place? Incidentally, when I added a SECOND upcoming event to the calendar, and commented out my if/then, the problem persisted. This problem appeared ONLY after I added an event in the near future...

I am attempting to figure out what would lead to COM_createLink being called with no $attr, but I could use some help.

Note that in the function declaration itself, $attr is defaulted to an empty, new array (!!!) -- note the code "$attr = array()" in the function declaration. Yet you can't foreach() an empty array; PHP throws an error. So isn't the default behaviour something impossible?

Perhaps my if/then isn't so much of a kluge after all...

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


More information about the geeklog-devel mailing list