1--TEST--
2Phar: delete a file within a zip-based .phar (confirm disk file is changed)
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7phar.require_hash=0
8--FILE--
9<?php
10
11$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
12$alias = 'phar://' . $fname;
13
14$phar = new Phar($fname);
15$phar['a.php'] = '<?php echo "This is a\n"; ?>';
16$phar['b.php'] = '<?php echo "This is b\n"; ?>';
17$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
18$phar->setStub('<?php __HALT_COMPILER(); ?>');
19$phar->stopBuffering();
20
21if (function_exists("opcache_get_status")) {
22	$status = opcache_get_status();
23	if ($status["opcache_enabled"]) {
24		ini_set("opcache.revalidate_freq", "0");
25		sleep(2);
26	}
27}
28
29include $alias . '/a.php';
30include $alias . '/b.php';
31include $alias . '/b/c.php';
32
33$md5 = md5_file($fname);
34unlink($alias . '/b/c.php');
35clearstatcache();
36$md52 = md5_file($fname);
37if ($md5 == $md52) echo 'file was not modified';
38?>
39===AFTER===
40<?php
41include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/a.php';
42include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/b.php';
43include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/b/c.php';
44?>
45
46===DONE===
47--CLEAN--
48<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
49--EXPECTF--
50This is a
51This is b
52This is b/c
53===AFTER===
54This is a
55This is b
56
57Warning: include(%sdelete_in_phar_confirm.phar.zip/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.zip" in %sdelete_in_phar_confirm.php on line %d
58
59Warning: include(): Failed opening 'phar://%sdelete_in_phar_confirm.phar.zip/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d
60
61===DONE===
62