Bug #75031 [Opn->Csd]: Stream php://temp incorrectly implements A+ mode

From: Date: Fri, 04 Aug 2017 11:44:06 +0000
Subject: Bug #75031 [Opn->Csd]: Stream php://temp incorrectly implements A+ mode
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210474@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75031&edit=1 ID: 75031 Updated by: krakjoe@php.net Reported by: jocrutrisi at ibsats dot com Summary: Stream php://temp incorrectly implements A+ mode -Status: Open +Status: Closed Type: Bug Package: Filesystem function related Operating System: All PHP Version: 7.2.0beta2 Block user comment: N Private report: N New Comment: Automatic comment on behalf of as Revision: http://git.php.net/?p=php-src.git;a=commit;h=db96b7c245907ef533c9dd7dc226b839df1a9341 Log: Fix #75031: Support append mode in php://temp streams Previous Comments: ------------------------------------------------------------------------ [2017-08-04 06:13:19] as@php.net https://github.com/php/php-src/pull/2671 ------------------------------------------------------------------------ [2017-08-03 21:51:07] jocrutrisi at ibsats dot com Description: ------------ The example demonstrates a discrepancy in A+ mode between a file stream, and a php://temp stream. According to docs, the file stream is correct, and php://temp is wrong here. Interesting this is not new, apparently all PHP versions do this, even HHVM: https://3v4l.org/6KlYg But both streams should behave the same, so something is off. Test script: --------------- <?php function test($a) { fwrite($a, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'); fseek($a, 0); fwrite($a, '1234567890'); fseek($a, 0); var_dump(fread($a, 1024)); fclose($a); } $a = fopen('php://temp', 'a+'); test($a); echo '-------------------' . PHP_EOL; $a = fopen(tempnam(sys_get_temp_dir(), "hello"), 'a+'); test($a); Expected result: ---------------- string(36) "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" ------------------- string(36) "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" Actual result: -------------- string(26) "1234567890KLMNOPQRSTUVWXYZ" ------------------- string(36) "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75031&edit=1

« previous php.bugs (#210474) next »