Category
bug · php-src-strict · stdlib touch()
Problem
Zend’s touch($filename, $mtime, $atime) sets both timestamps. The VM returns true but leaves filemtime / fileatime at “now”, ignoring both the 2-arg and 3-arg forms.
Reflection already tracks optional ?int typing separately (#28558); this issue is the behavioral timestamp write.
Verified 2026-08-08 in ./script/docker-exec.sh vs host Zend 8.2.32.
| Repro |
Zend 8.2 |
VM (2026-08-08) |
touch($p, 1600000000, 1599999900) then filemtime / fileatime |
1600000000 / 1599999900 |
current unix time / current unix time |
touch($p, 1600000000) (2-arg) |
filemtime === 1600000000 |
filemtime stays “now” |
php-src reference
PHP implementation target
ext/standard/VmFsTouch*.php / FsDirJitHelper::touch — pass through $mtime / $atime to the native touch/utime path instead of always using “now”
- When
$atime is omitted, Zend sets atime from mtime (2-arg); match that
- No new
runtime/*.c beyond thin ABI if a native utime trampoline already exists
Repro
./script/docker-exec.sh -- bash -lc 'cat > /tmp/touch_mtime.php <<'"'"'PHP'"'"'
<?php
$p = tempnam(sys_get_temp_dir(), "pc");
$mtime = 1600000000;
$atime = 1599999900;
touch($p, $mtime, $atime);
echo "mtime_ok=", filemtime($p) === $mtime ? "y" : "n", "\n";
echo "atime_ok=", fileatime($p) === $atime ? "y" : "n", "\n";
unlink($p);
PHP
php /tmp/touch_mtime.php; echo ---; php bin/vm.php /tmp/touch_mtime.php'
Done when
Related
Category
bug· php-src-strict · stdlibtouch()Problem
Zend’s
touch($filename, $mtime, $atime)sets both timestamps. The VM returnstruebut leavesfilemtime/fileatimeat “now”, ignoring both the 2-arg and 3-arg forms.Reflection already tracks optional
?inttyping separately (#28558); this issue is the behavioral timestamp write.Verified 2026-08-08 in
./script/docker-exec.shvs host Zend 8.2.32.touch($p, 1600000000, 1599999900)thenfilemtime/fileatime1600000000/1599999900touch($p, 1600000000)(2-arg)filemtime === 1600000000filemtimestays “now”php-src reference
ext/standard/filestat.c—PHP_FUNCTION(touch)→utime/utimeswith optionalmtime/atimefunction touch(string $filename, ?int $mtime = null, ?int $atime = null): boolPHP implementation target
ext/standard/VmFsTouch*.php/FsDirJitHelper::touch— pass through$mtime/$atimeto the native touch/utimepath instead of always using “now”$atimeis omitted, Zend sets atime from mtime (2-arg); match thatruntime/*.cbeyond thin ABI if a native utime trampoline already existsRepro
Done when
touch()setfilemtime/fileatimelike Zend.phptundertest/compliance/cases/Related