Invalid argument supplied for foreach()

Having trouble installing serendipity?
Post Reply
RadBryan

Invalid argument supplied for foreach()

Post by RadBryan »

When attempting to install the b4 release, I get the following errors (when choosing "Expert Installation":

Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/reasonableness.com/httpdocs/blog/include/functions_installer.inc.php on line 370 (Repeated 5 times)

I click "Complete Installation" and these errors occur:

Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/reasonableness.com/httpdocs/blog/include/admin/installer.inc.php on line 35 (Repeated 5 times)

Fatal error: Call to undefined function: serendipity_db_probe() in /home/httpd/vhosts/reasonableness.com/httpdocs/blog/include/functions_installer.inc.php on line 527


This is with PHP 4.3.10, MySQL, no Imagemagick library.

Any ideas? (I've installed previous 7.x releases of Serendipity on different servers, never encountered problems like this before.)

Thanks!
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Invalid argument supplied for foreach()

Post by garvinhicking »

This error seems to happen because serendipity cannot parse the file include/tpl/config_local.inc.php - check if that file exists?

Maybe you got a corrupted tarball.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
RadBryan

Post by RadBryan »

Thanks for the response Garvin.

Double checked, and include/tpl/config_local.inc.php exists, has permissions set wide open (rwx all) and doesn't look to be corrupted at all.

Any other ideas? :)
RadBryan

Post by RadBryan »

Just tried again with the b5 released today with the same errors.

(Since I started trying to get Serendipity setup I've been able to install phpBB without problem, so PHP isn't having trouble talking to my MySQL db.)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

This may be caused by a special CGI setup of php. Can you give me a link to a phpinfo() output? I cannot reproduce this anywhere on my machine :(

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
RadBryan

Post by RadBryan »

Sure thing. Here is the phpinfo page:
http://www.reasonableness.com/phpinfo/info.php
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Wow. I've never seen such a overfilled PHP/Apache combination! You load about any module that is available; I'm quite sury any of these modules create trouble; maybe some of the encoders or additional modules.

I'm really sorry, but this is too hard to debug, there are just so many components which could act weird. I can only offer you to look at it if you give me FTP access to the blog directory, then I'll do some debugging.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
RadBryan
Posts: 1
Joined: Tue Apr 05, 2005 2:30 am

Post by RadBryan »

Private message sent. :)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Thanks to the help of RadBryan by supplying me with FTP data, I got his problem down to a thing.

Bryan, your PHP installation is garbaged. It produces wrong results when iterating through an array. I created a test.php:

Code: Select all

<?php
$test = array(
    'database' => array(
        'items' => array(
            array(
                'var'     => '1',
                'nothing' => '2'),

            array(
                'var'     => '3',
                'nothing' => '4')
        )
    ),
    
    'paths' => array(
        'items' => array(
            array(
                'var'     => '1',
                'nothing' => '2'),

            array(
                'var'     => '3',
                'nothing' => '4')
        )
    )
);

print_r($test);

foreach($test AS $category) {
    print_r($category);
}
This produces this output on your machine

Code: Select all

Array
(
    [database] => Array
        (
            [items] => Array
                (
                    [0] => Array
                        (
                            [var] => 1
                            [nothing] => 2
                        )

                    [1] => Array
                        (
                            [var] => 3
                            [nothing] => 4
                        )

                )

        )

    [paths] => Array
        (
            [items] => Array
                (
                    [0] => Array
                        (
                            [var] => 1
                            [nothing] => 2
                        )

                    [1] => Array
                        (
                            [var] => 3
                            [nothing] => 4
                        )

                )

        )

)
Array
(
    [0] => Array
        (
            [items] => Array
                (
                    [0] => Array
                        (
                            [var] => 1
                            [nothing] => 2
                        )

                    [1] => Array
                        (
                            [var] => 3
                            [nothing] => 4
                        )

                )

        )

    [1] => database
)
Array
(
    [0] => Array
        (
            [items] => Array
                (
                    [0] => Array
                        (
                            [var] => 1
                            [nothing] => 2
                        )

                    [1] => Array
                        (
                            [var] => 3
                            [nothing] => 4
                        )

                )

        )

    [1] => paths
)
while this is the output that is produced on a right server:

Code: Select all

Array
(
    [database] => Array
        (
            [items] => Array
                (
                    [0] => Array
                        (
                            [var] => 1
                            [nothing] => 2
                        )

                    [1] => Array
                        (
                            [var] => 3
                            [nothing] => 4
                        )

                )

        )

    [paths] => Array
        (
            [items] => Array
                (
                    [0] => Array
                        (
                            [var] => 1
                            [nothing] => 2
                        )

                    [1] => Array
                        (
                            [var] => 3
                            [nothing] => 4
                        )

                )

        )

)
Array
(
    [items] => Array
        (
            [0] => Array
                (
                    [var] => 1
                    [nothing] => 2
                )

            [1] => Array
                (
                    [var] => 3
                    [nothing] => 4
                )

        )

)
Array
(
    [items] => Array
        (
            [0] => Array
                (
                    [var] => 1
                    [nothing] => 2
                )

            [1] => Array
                (
                    [var] => 3
                    [nothing] => 4
                )

        )

)

As you can see, your PHP module returns completely wrong array indizes.

For PHP 4.3.10 this can happen because they changed the bytecode of the foreach() operation. This caused quite some seroius bugs using the zendEncoder or other zend bytecode compilers, causing the exact same problem.

As your phpinfo() tells that you are using the ionCube encode, it looks that this is creating the trouble for you. Deactivate that module and you should be fine!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply