Bug #75031 [NEW]: Stream php://temp incorrectly implements A+ mode

From: Date: Thu, 03 Aug 2017 21:51:12 +0000
Subject: Bug #75031 [NEW]: Stream php://temp incorrectly implements A+ mode
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210466@lists.php.net to get a copy of this message
From: jocrutrisi at ibsats dot com Operating system: All PHP version: 7.2.0beta2 Package: Filesystem function related Bug Type: Bug Bug description:Stream php://temp incorrectly implements A+ mode 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 bug report at https://bugs.php.net/bug.php?id=75031&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75031&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75031&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75031&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75031&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75031&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75031&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75031&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75031&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75031&r=support Expected behavior: https://bugs.php.net/fix.php?id=75031&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75031&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75031&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75031&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75031&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75031&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75031&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75031&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75031&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75031&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75031&r=mysqlcfg

« previous php.bugs (#210466) next »