Bug #76900 [Com]: overwriting start of stream truncates the end

From: Date: Tue, 18 Sep 2018 23:51:30 +0000
Subject: Bug #76900 [Com]: overwriting start of stream truncates the end
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217131@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76900&edit=1 ID: 76900 Comment by: a at b dot c dot de Reported by: sjon at hortensius dot net Summary: overwriting start of stream truncates the end Status: Not a bug Type: Bug Package: Streams related Operating System: archLinux PHP Version: 7.3.0RC1 Block user comment: N Private report: N New Comment: As for "the previous available data is gone" bit... <?php $socket = fopen('php://memory', 'a+'); fwrite($socket, 'ab'); fseek($socket, 0); fwrite($socket, 'a'); fseek($socket, 0); var_dump(fgets($socket)); Previous Comments: ------------------------------------------------------------------------ [2018-09-18 14:13:02] requinix@php.net See bug #75031. http://php.net/manual/en/function.fopen.php > 'a+' > ...In this mode, fseek() only affects the reading position, writes are always appended. ------------------------------------------------------------------------ [2018-09-18 14:06:26] sjon at hortensius dot net Description: ------------ after fseeking a stream and fwriting less data to it, the previous available data is gone See https://3v4l.org/2haHa Test script: --------------- <?php $socket = fopen('php://memory', 'a+'); fwrite($socket, 'ab'); fseek($socket, 0); fwrite($socket, 'a'); var_dump(fgets($socket)); Expected result: ---------------- string(1) "b" Actual result: -------------- bool(false) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76900&edit=1

« previous php.bugs (#217131) next »