Bug #72983 [NEW]: file_put_contents does not overwrite if file exists
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)
- jim dot michaels at Jesusnjim dot com
- cmb@php.netBug #72983 [Opn->Fbk]: file_put_contents does not overwrite if file exists
- jmichae3 at yahoo dot comBug #72983 [Com]: file_put_contents does not overwrite if file exists
- fernando at null-life dot comBug #72983 [Com]: file_put_contents does not overwrite if file exists
- cmb@php.netBug #72983 [Fbk]: file_put_contents does not overwrite if file exists
- jim dot michaels at Jesusnjim dot comBug #72983 [Fbk->Asn]: file_put_contents does not overwrite if file exists
- requinix@php.netBug #72983 [Asn->Nab]: file_put_contents does not overwrite if file exists
- jmichae3 at yahoo dot comBug #72983 [Com]: file_put_contents does not overwrite if file exists
- jmichae3 at yahoo dot comBug #72983 [Com]: file_put_contents does not overwrite if file exists
- requinix@php.netBug #72983 [Nab]: file_put_contents does not overwrite if file exists
- cmb@php.netBug #72983 [Nab]: file_put_contents does not overwrite if file exists
- jmichae3 at yahoo dot comBug #72983 [Com]: file_put_contents does not overwrite if file exists
- requinix@php.netBug #72983 [Nab]: file_put_contents does not overwrite if file exists
- jim dot michaels at Jesusnjim dot comBug #72983 [Nab]: file_put_contents does not overwrite if file exists
- requinix@php.netBug #72983 [Nab]: file_put_contents does not overwrite if file exists