From:             gfraley5 at earthlink dot net
Operating system: Windows XP
PHP version:      4.3.2RC1
PHP Bug Type:     Filesystem function related
Bug description:  Incorrectly writes out data.

The following code works correctly on 4.3.1 (and prior) but does not appear
to work correctly on 4.3.2RC1.  I have only tested this on Windows XP.

<?
        $fp = fopen("php432.csv.php",'r') or die("Problem");
        while ($data = fgetcsv($fp,1024,",")) {
                $row++;
                if ($row<1) continue;
                $gcf = $data;
        }
        fclose($fp);

        $fp = fopen("php432.csv.php",'w') or die("Problem");
        flock($fp,2);
        for ($i=0;$i<count($gcf);$i++) {
                if ($i==0) $prefx = "<? Header(\"HTTP/1.0 403 Forbidden\");exit; ?>\n";
                else $prefx = "";
                fwrite($fp,$prefx.$gcf[$i].',');
                if ($i<count($gcf)-1) fwrite($fp,',');          
        }
        flock($fp,3);
        fclose($fp);
?>


Here is a simple example of the file that is read in (php432.csv.php):

<? Header("HTTP/1.0 403 Forbidden");exit; ?>
1043203275,localhost,2003-01-21,20:41:15,Anonymous,,,,,,,,blank,Test,,

When run under 4.3.1, it correctly writes out
<? Header("HTTP/1.0 403 Forbidden");exit; ?>
1043203275,localhost,2003-01-21,20:41:15,Anonymous,,,,,,,,blank,Test,,

However, under 4.3.2RC1, it truncates the last digit (5) from the first
field.  It writes out
<? Header("HTTP/1.0 403 Forbidden");exit; ?>
104320327,localhost,2003-01-21,20:41:15,Anonymous,,,,,,,,blank,Test,,

There is other erratic behavior also.  If I modify the code to include a
header row in line 2, and modify the code accordingly, it will skip the
first comma separator like this:

1043203275localhost,2003-01-21,20:41:15,Anonymous,,,,,,,,blank,Test,,.  

I have not included that code for brevity.
-- 
Edit bug report at http://bugs.php.net/?id=22810&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=22810&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=22810&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=22810&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=22810&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=22810&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=22810&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=22810&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=22810&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=22810&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=22810&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22810&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=22810&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=22810&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=22810&r=gnused

Reply via email to