Page 1 of 1

Upgraded v1.1 Beta5 from v1.0.1 -- PHP Warnings under Edit

Posted: Fri Nov 24, 2006 3:04 am
by Brendon K
When editing a story, I still receive two PHP Warnings (not notices, but I have my PHP set to display those as well) when attempting to edit an entry.

1.) Warning: Invalid argument supplied for foreach() in C:\Apache\htdocs\s9y\include\functions.inc.php on line 311

2.) Warning: Invalid argument supplied for foreach() in C:\Apache\htdocs\s9y\include\functions.inc.php on line 329

Like stated in the topic title, this was an upgrade. I will check tomorrow to see if it still shows this error on a clean install (though I would think it does). Since I also have Xdebug installed on my test server, it really screws up the layout of the administration section when these errors are displayed, but I notice if entries are available to be edited, they're outside the bounding box of the administration section (below the outer-most border) in Firefox, not IE(6). I haven't tested Opera. Not sure if it would occur without the long error messages or not.

Re: Upgraded v1.1 Beta5 from v1.0.1 -- PHP Warnings under Ed

Posted: Fri Nov 24, 2006 9:44 am
by garvinhicking
Hi!

Which PHP version are you using?

The function which makes the error is a foreach loop on an $ary variable.

However this check at the top of the serendipity_walkRecursive function should detect that:

Code: Select all

    if (!is_array($ary) || sizeof($ary) == 0) {
        return array();
    }
So I wonder why this is not stepping in for you. Can you do a "print_r($ary)" in that function to see what the variable looks like that is yielding those errors?

Best regards,
Garvin

Posted: Sun Nov 26, 2006 2:06 am
by Brendon K
The following check was the only one found in my file's copy:

Code: Select all

    if (sizeof($ary) == 0) {
        return array();
    }
At the top of the file, the version comments are as follows:

Code: Select all

# $Id: functions.inc.php 1413 2006-08-27 11:29:00Z garvinhicking $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved.  See LICENSE file for licensing details
I'm currently using PHP v5.1.6 with a slightly modified php.ini-recommended file under WinXP Pro.

I'm guessing that perhaps your local copy and the copy in the repository aren't the same? (I downloaded this version from the SourceForge package.) Once I make the check the same as the version you gave, it works perfectly fine. No errors, warnings, or notices are generated (and the display error no longer exists).