Bug #51640 [Bgs]: Fwrite writes twice a text

2010-06-10 Thread spiderboy1989 at gmail dot com
Edit report at http://bugs.php.net/bug.php?id=51640edit=1

 ID:   51640
 User updated by:  spiderboy1989 at gmail dot com
 Reported by:  spiderboy1989 at gmail dot com
 Summary:  Fwrite writes twice a text
 Status:   Bogus
 Type: Bug
 Package:  Filesystem function related
 Operating System: Windows XP
 PHP Version:  5.3.2

 New Comment:

No way... i tested again, the same code, the same code that was giving
me troubles... I tested the g_i_ivanov's code, and both are working!
This must be a joke... I didn't change php version, I didn't change the
code... This can't be true :/...



I'm sorry for wasting your time. If I see any weird behavior, I will let
you know it.


Previous Comments:

[2010-06-08 14:09:43] tony2...@php.net

Not reproducible.

Try providing a working example script, the one in the report doesn't
work.


[2010-06-01 10:19:44] g_i_ivanov at mail dot bg

I have the same problem: 



Windows XP Professional SP3, Apache/2.2.14, PHP 5.2.13 (cli)



code:

--

$fp = fopen(d:/Projects/test/logs/testfile.txt, a);

fwrite($fp, date('c') .  - Sample text . PHP_EOL);

fclose($fp);



result: 

--

2010-05-31T10:36:37+03:00 - Sample text

2010-05-31T10:36:37+03:00 - Sample text


[2010-04-23 01:57:42] spiderboy1989 at gmail dot com

Description:

I'm having troubles with fwrite() function. It is writing twice a text I
just need to write once. I searched in google for the same problem, and
I found the same bug reported here :
http://bugs.php.net/bug.php?id=21916, and here :
http://bugs.php.net/bug.php?id=16225, but neither of both was solved. 



This is how it writes into the file :



First



Second



Hello world!

Hello world!

Third



As you can see, the string hello world! is writed twice, and that
should not happen. Also, and this is weird, the line fwrite($op,
$lastLine); prints the text correctly, just once...



Test script:
---
$file = test.txt;

$string = Hello world!\r\n;

$op = fopen($file,r+);

$exp = explode(\n, fread($op, filesize($file)));

$lastLine = end($exp);

fseek($op, -strlen($lastLine), SEEK_END);

fwrite($op, $string);

fwrite($op, $lastLine);

fclose($op);

Expected result:

The text should be writed just once.







-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51640edit=1


[PHP-BUG] Bug #51640 [NEW]: Fwrite writes twice a text

2010-04-22 Thread spiderboy1989 at gmail dot com
From: 
Operating system: Windows XP
PHP version:  5.3.2
Package:  Filesystem function related
Bug Type: Bug
Bug description:Fwrite writes twice a text

Description:

I'm having troubles with fwrite() function. It is writing twice a text I
just need to write once. I searched in google for the same problem, and I
found the same bug reported here : http://bugs.php.net/bug.php?id=21916,
and here : http://bugs.php.net/bug.php?id=16225, but neither of both was
solved. 



This is how it writes into the file :



First



Second



Hello world!

Hello world!

Third



As you can see, the string hello world! is writed twice, and that should
not happen. Also, and this is weird, the line fwrite($op, $lastLine);
prints the text correctly, just once...



Test script:
---
$file = test.txt;

$string = Hello world!\r\n;

$op = fopen($file,r+);

$exp = explode(\n, fread($op, filesize($file)));

$lastLine = end($exp);

fseek($op, -strlen($lastLine), SEEK_END);

fwrite($op, $string);

fwrite($op, $lastLine);

fclose($op);

Expected result:

The text should be writed just once.


-- 
Edit bug report at http://bugs.php.net/bug.php?id=51640edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=51640r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=51640r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=51640r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=51640r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51640r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=51640r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=51640r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=51640r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=51640r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=51640r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=51640r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=51640r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=51640r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=51640r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=51640r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=51640r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=51640r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=51640r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=51640r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=51640r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=51640r=mysqlcfg