File tree Expand file tree Collapse file tree
ext/phar/tests/buildFromIterator_user_overrides Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,6 +184,8 @@ PHP NEWS
184184 mounted entries). (Lazizbek Ergashev)
185185 . Fixed bug GH-24531 (Crash when modifying a zip-based phar whose file was
186186 renamed). (Ilia Alshanetsky)
187+ . Fixed Phar::buildFromIterator() accepting a negative getMTime() on 32bit
188+ platforms. (Marc Bennewitz)
187189
188190- Reflection:
189191 . Fixed bug GH-21768 (Assertion failure in ReflectionProperty::isReadable()
Original file line number Diff line number Diff line change 1+ --TEST--
2+ buildFromIterator with user overrides - negative getMTime()
3+ --EXTENSIONS--
4+ phar
5+ --INI--
6+ phar.readonly=0
7+ phar.require_hash=0
8+ --FILE--
9+ <?php
10+
11+ class MySplFileInfo extends SplFileInfo {
12+ public function getMTime (): int |false {
13+ echo "[MTime] \n" ;
14+ return -1 ;
15+ }
16+ }
17+
18+ class MyIterator extends RecursiveDirectoryIterator {
19+ public function current (): SplFileInfo {
20+ return new MySplFileInfo (parent ::current ()->getPathname ());
21+ }
22+ }
23+
24+ $ workdir = __DIR__ .'/getMTime_negative ' ;
25+ mkdir ($ workdir . '/content ' , recursive: true );
26+ file_put_contents ($ workdir . '/content/hello.txt ' , "Hello world. " );
27+
28+ try {
29+ $ phar = new \Phar ($ workdir . "/test.phar " );
30+ $ phar ->startBuffering ();
31+ $ phar ->buildFromIterator (
32+ new RecursiveIteratorIterator (
33+ new MyIterator ($ workdir . '/content ' , FilesystemIterator::SKIP_DOTS )
34+ ),
35+ $ workdir
36+ );
37+ $ phar ->stopBuffering ();
38+ } catch (Throwable $ e ) {
39+ echo $ e ::class, ': ' , $ e ->getMessage (), "\n" ;
40+ }
41+
42+ ?>
43+ --CLEAN--
44+ <?php
45+ $ workdir = __DIR__ .'/getMTime_negative ' ;
46+ @unlink ($ workdir . '/content/hello.txt ' );
47+ @unlink ($ workdir . '/test.phar ' );
48+ @rmdir ($ workdir . '/content ' );
49+ @rmdir ($ workdir );
50+ ?>
51+ --EXPECTF--
52+ [MTime]
53+ BadMethodCallException: Entry content%chello.txt cannot be created: timestamp is limited to 32-bit
You can’t perform that action at this time.
0 commit comments