Bug #76900 [Opn->Nab]: overwriting start of stream truncates the end

From: Date: Tue, 18 Sep 2018 14:13:02 +0000
Subject: Bug #76900 [Opn->Nab]: overwriting start of stream truncates the end
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217118@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 Updated by: requinix@php.net Reported by: sjon at hortensius dot net Summary: overwriting start of stream truncates the end -Status: Open +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: 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. Previous Comments: ------------------------------------------------------------------------ [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 (#217118) next »