xref: /PHP-7.0/ext/phar/tests/bug74991.phpt (revision 6b1fbafd)
1--TEST--
2Phar: PHP bug #74991: include_path has a 4096 char (minus "__DIR__:") limit, in some PHAR cases
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip");
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9// create a sample file in a custom include_path to lookup from the phar later:
10mkdir('path');
11touch('path/needle.php');
12$p = new Phar('sample.phar');
13// the use of a sub path is crucial, and make the include_path 1 byte larger (=OVERFLOW) than the MAXPATHLEN, the include_path will then be truncated to 4096 (MAXPATHLEN) into 'phar://..sample.phar/some:xx..xx:pat' so it will fail to find needle.php:
14$p['some/file'] = "<?php const MAXPATHLEN = 4096, OVERFLOW = 1, PATH = 'path'; set_include_path(str_repeat('x', MAXPATHLEN - strlen(__DIR__ . PATH_SEPARATOR . PATH_SEPARATOR . PATH) + OVERFLOW) . PATH_SEPARATOR . PATH); require('needle.php');";
15$p->setStub("<?php Phar::mapPhar('sample.phar'); __HALT_COMPILER();");
16// execute the phar code:
17require('phar://sample.phar/some/file');
18--CLEAN--
19<?php
20unlink('path/needle.php');
21unlink('sample.phar');
22rmdir('path');
23--EXPECT--
24