|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-08-30 12:43 UTC] cmb@php.net
-Status: Open
+Status: Verified
[2021-08-30 12:43 UTC] cmb@php.net
[2024-07-24 06:24 UTC] jeffrey597doss at outlook dot com
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 19:00:01 2025 UTC |
Description: ------------ fflush file make strange result in phar files. this occurs on PHP 7.4 also, tested in windows and linux use php -n -dphar.readonly=0 test.php to test Test script: --------------- <?php // make up the phar $phar = new \Phar(__DIR__ . DIRECTORY_SEPARATOR . 'test.phar'); $phar->addEmptyDir('dir'); // may be irrelative $phar->stopBuffering(); //$phar_uri = __DIR__ . DIRECTORY_SEPARATOR . 'file'; $phar_uri = 'phar://' . __DIR__ . DIRECTORY_SEPARATOR . 'test.phar' . DIRECTORY_SEPARATOR . 'dir/file'; // make a file $f = fopen($phar_uri, 'w+'); fwrite($f, 'this is content '); fflush($f); // comment out this, things will be ok fwrite($f, "of file.\n"); fclose($f); // read it $f = fopen($phar_uri, 'r'); $content = fread($f, 4096); if ($content !== "this is content of file.\n") { throw new Exception("bad file context: $content vs 'this is content of file.\n'"); } else { echo "OK\n"; } Expected result: ---------------- OK Actual result: -------------- bad file context with strange things