Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ PHP NEWS
mounted entries). (Lazizbek Ergashev)
. Fixed bug GH-24531 (Crash when modifying a zip-based phar whose file was
renamed). (Ilia Alshanetsky)
. Fixed Phar::buildFromIterator() accepting a negative getMTime() on 32bit
platforms. (Marc Bennewitz)

- Reflection:
. Fixed bug GH-21768 (Assertion failure in ReflectionProperty::isReadable()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
--TEST--
buildFromIterator with user overrides - negative getMTime()
--EXTENSIONS--
phar
--INI--
phar.readonly=0
phar.require_hash=0
--FILE--
<?php

class MySplFileInfo extends SplFileInfo {
public function getMTime(): int|false {
echo "[MTime]\n";
return -1;
}
}

class MyIterator extends RecursiveDirectoryIterator {
public function current(): SplFileInfo {
return new MySplFileInfo(parent::current()->getPathname());
}
}

$workdir = __DIR__.'/getMTime_negative';
mkdir($workdir . '/content', recursive: true);
file_put_contents($workdir . '/content/hello.txt', "Hello world.");

try {
$phar = new \Phar($workdir . "/test.phar");
$phar->startBuffering();
$phar->buildFromIterator(
new RecursiveIteratorIterator(
new MyIterator($workdir . '/content', FilesystemIterator::SKIP_DOTS)
),
$workdir
);
$phar->stopBuffering();
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--CLEAN--
<?php
$workdir = __DIR__.'/getMTime_negative';
@unlink($workdir . '/content/hello.txt');
@unlink($workdir . '/test.phar');
@rmdir($workdir . '/content');
@rmdir($workdir);
?>
--EXPECTF--
[MTime]
BadMethodCallException: Entry content%chello.txt cannot be created: timestamp is limited to 32-bit
Loading