xref: /PHP-8.4/ext/phar/tests/bug13786.phpt (revision 74859783)
1--TEST--
2Phar: bug #13786: "PHP crashes on phar recreate after unlink"
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10
11try {
12for ($i = 0; $i < 2; $i++) {
13    $fname = "DataArchive.phar";
14    $path = __DIR__ . DIRECTORY_SEPARATOR . $fname;
15    $phar = new Phar($path);
16    $phar->addFromString($i, "file $i in $fname");
17    var_dump(file_get_contents($phar[$i]));
18    unset($phar);
19    unlink($path);
20}
21
22echo("\nWritten files: $i\n");
23} catch (Exception $e) {
24echo $e->getMessage() . "\n";
25}
26
27?>
28--EXPECTF--
29string(26) "file 0 in DataArchive.phar"
30unable to seek to start of file "0" while creating new phar "%sDataArchive.phar"
31