Bug #72983 [NEW]: file_put_contents does not overwrite if file exists

From: Date: Wed, 31 Aug 2016 03:00:10 +0000
Subject: Bug #72983 [NEW]: file_put_contents does not overwrite if file exists
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203693@lists.php.net to get a copy of this message
From:             jim dot michaels at Jesusnjim dot com
Operating system: vista x32 amd
PHP version:      7.1.0beta3
Package:          Filesystem function related
Bug Type:         Bug
Bug description:file_put_contents does not overwrite if file exists

Description:
------------
file_put_contents() does not overwrite if file exists. if file exists,
file is not touched. if file is open in programmer's editor, rw.txt file
does not refresh. this could be related with c++ old gcc bug in
fstream's std::ios_base::creat notworking for while a number of years.


Test script:
---------------
<?php
$a=file_get_contents("\\w\\Jesusnjim\\menu7a.xml");
$a=preg_replace('/\//','\\',$a);
file_put_contents("\\w\\Jesusnjim\\rw.txt", $a);
?>

2nd time:
<?php
$a=file_get_contents("\\w\\Jesusnjim\\menu7a.xml");
$a=preg_replace('/\//','\\\\',$a);
file_put_contents("\\w\\Jesusnjim\\rw.txt", $a);
?>

Expected result:
----------------
expected / to be changed to \\ and for rw.txt to be changed in
programmer's editor jedit and to be notified that file was changed.

Actual result:
--------------
if file is open in programmer's editor, rw.txt file does not refresh.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=72983&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=72983&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=72983&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=72983&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=72983&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=72983&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=72983&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=72983&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=72983&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=72983&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=72983&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=72983&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=72983&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=72983&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72983&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=72983&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=72983&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=72983&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72983&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=72983&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=72983&r=mysqlcfg



Thread (15 messages)

« previous php.bugs (#203693) next »