1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/phar/tests/SplFileInfo_openFile_write.phpt
Niels Dossche efde160ef4 phar: Fix SplFileInfo::openFile() in write mode
This stopped working after e735d2bc3b because fp_refcount is increased,
making phar think that the file has open read pointers.
To fix this, the refcount shouldn't be increased but that would
re-introduce the previous bug.
Instead, we need to add a field that "locks" the existence of the
internal entry separate from the refcount.

Closes GH-20473.
2025-12-21 13:17:54 +01:00

32 lines
672 B
PHP

--TEST--
SplFileInfo::openFile() in write mode
--EXTENSIONS--
phar
--INI--
phar.readonly=0
--FILE--
<?php
$phar = new Phar(__DIR__.'/SplFileInfo_openFile_write.phar');
$phar->addFromString('test', 'contents');
var_dump($phar['test']->openFile('w'));
?>
--CLEAN--
<?php
@unlink(__DIR__.'/SplFileInfo_openFile_write.phar');
?>
--EXPECTF--
object(SplFileObject)#%d (%d) {
["pathName":"SplFileInfo":private]=>
string(%d) "phar://%stest"
["fileName":"SplFileInfo":private]=>
string(4) "test"
["openMode":"SplFileObject":private]=>
string(1) "w"
["delimiter":"SplFileObject":private]=>
string(1) ","
["enclosure":"SplFileObject":private]=>
string(1) """
}