|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-03-28 23:08 UTC] nazar at mokrynskyi dot com
Description:
------------
Test script is very simple, but when I run it - I get:
> PHP Fatal error: Uncaught exception 'PharException' with message 'unable to seek to start of file
Note, that if we add one file (no matter the same or different) - it works fine, it two (no matter the same or different) - it crashes with exception.
My thoughts are that after unsetting $phar, file is not properly closed and there is some uncleaned cache present.
I can send pull request with this test case added on GitHub.
Test script:
---------------
<?php
ini_set('display_errors', 1);
file_put_contents('test', 'some content');
$phar = new Phar('build.phar');
$phar->addFile('test', 'test');
$phar->addFile('test', 'test2');
unset($phar);
rename('build.phar', 'build2.phar');
$phar = new Phar('build.phar');
$phar->addFile('test', 'test');
echo "ok";
Expected result:
----------------
ok
Actual result:
--------------
Fatal error: Uncaught exception 'PharException' with message 'unable to seek to start of file "test2" while creating new phar "/path/build.phar"' in /path/build.php:10 Stack trace: #0 /path/build.php(10): Phar->addFile('test', 'test') #1 {main} thrown in /path/build.php on line 10
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 20:00:01 2025 UTC |
That does seem to be an issue - it's possible with code that doesn't involve unet as well. function foo() { ini_set('display_errors', 1); file_put_contents('test', 'some content'); $phar = new Phar('build.phar'); $phar->addFile('test', 'test'); $phar->addFile('test', 'test2'); } function bar() { $phar = new Phar('build.phar'); $phar->addFile('test', 'test'); echo "ok"; } foo(); rename('build.phar', 'build2.phar'); bar();