Welcome to Geeklog Tuesday, January 21 2020 @ 09:12 pm EST

Geeklog Forums

Odd Error


Status: offline

trampoline

Forum User
Full Member
Registered: 24/02/06
Posts: 392
I get this error but only once a week or so....

An error has occurred:
2 - Invalid argument supplied for foreach() @ /Library/WebServer/commun/Documents/lib-common.php line 4723

when i load the main page of one of my sites however if i load again it goes away....????
Something must be wrong ?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
Which Geeklog version is that? There's no foreach in or near line 4723 in Geeklog 1.4.1 ...

bye, Dirk
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 24/02/06
Posts: 392
1.4.1 this is the function...
PHP Formatted Code
function COM_makeList( $listofitems, $classname = '' )
{
    global $_CONF;

    $list = new Template( $_CONF['path_layout'] );
    $list->set_file( array( 'list'     => 'list.thtml',
                            'listitem' => 'listitem.thtml' ));
    $list->set_var( 'site_url', $_CONF['site_url'] );
    $list->set_var( 'layout_url', $_CONF['layout_url'] );
    if( empty( $classname ))
    {
        $list->set_var( 'list_class', '' );
        $list->set_var( 'list_class_name', '' );
    }
    else
    {
        $list->set_var( 'list_class', 'class="' . $classname . '"' );
        $list->set_var( 'list_class_name', $classname );
    }

    foreach( $listofitems as $oneitem )
    {
        $list->set_var( 'list_item', $oneitem );
        $list->parse( 'list_items', 'listitem', true );
    }

    $list->parse( 'newlist', 'list', true );

    return $list->finish( $list->get_var( 'newlist' ));
}
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
You must have modified your lib-common.php then, since COM_makeList only starts in line 4797.

Anyway, the problem is with whatever is calling that function. Do you have some sort of dynamic block on your site that displays items in a list? Looks like occasionally, it's calling COM_makeList with an empty data set.

The function should certainly be more fault tolerant, but the real problem is the calling entity.

bye, Dirk
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 24/02/06
Posts: 392
Quote by: Dirk

You must have modified your lib-common.php then, since COM_makeList only starts in line 4797.

Anyway, the problem is with whatever is calling that function. Do you have some sort of dynamic block on your site that displays items in a list? Looks like occasionally, it's calling COM_makeList with an empty data set.

The function should certainly be more fault tolerant, but the real problem is the calling entity.

bye, Dirk



I only have

GL Menu
Forum
MyCal in blocks on front page could it be one of those ???
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
I've just added a
PHP Formatted Code
if (is_array($listofitems)) {
in front of the foreach in CVS. I still think it's a problem in the calling entity, though. Hard to tell where it's coming from ...

bye, Dirk
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 24/02/06
Posts: 392
Thanks...I have altered as follows, is this correct ?
PHP Formatted Code

if (is_array($listofitems))
    foreach( $listofitems as $oneitem )
    {
        $list->set_var( 'list_item', $oneitem );
        $list->parse( 'list_items', 'listitem', true );
    }

    $list->parse( 'newlist', 'list', true );

    return $list->finish( $list->get_var( 'newlist' ));
}
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
Yep.

bye, Dirk
 Quote

Status: offline

trampoline

Forum User
Full Member
Registered: 24/02/06
Posts: 392
Great,
Site loads, in your example you wrote it as
PHP Formatted Code
if (is_array($listofitems)) {

Which failed to load, I guess because of the opening {
so I removed the { and it loads OK
Thanks, I guess it was some odd thing but at least the error will not effect anything now..
 Quote

All times are EST. The time is now 09:12 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content