Category
stdlib
Problem
tempnam() has several php-src-specific behaviors that should match Zend:
- Prefix is truncated to a max length (64) in php-src
- Invalid/non-existing
$directory falls back to system temp dir and emits a Notice
- Type validation and null-byte rejection should match Zend error/exception types
php-src reference
- Core temp file creation:
main/php_open_temporary_file.c
tempnam() implementation: ext/standard/file.c
- Tests:
ext/standard/tests/file/tempnam_variation9.phpt (prefix max length)
ext/standard/tests/file/tempnam_variation7-win32.phpt (invalid/non-existing dir fallback behavior)
ext/standard/tests/file/tempnam_variation4.phpt (null byte handling)
Repro
Save as repro_tempnam_prefix_fallback.php:
<?php
$dir = __DIR__ . '/tempnam-test';
@mkdir($dir);
$prefix = 'begin_' . str_repeat('x', 300) . '_end';
$f = tempnam($dir, $prefix);
echo "basename-len=", strlen(basename($f)), "\n";
unlink($f);
// Invalid dir: should fall back to sys_get_temp_dir() and emit a Notice.
$f2 = tempnam("/definitely/does/not/exist", "pfx");
echo "fallback-dir=", realpath(dirname($f2)) === realpath(sys_get_temp_dir()) ? 'yes' : 'no', "\n";
unlink($f2);
Run in Docker:
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro_tempnam_prefix_fallback.php
./phpc run repro_tempnam_prefix_fallback.php
# Today: prefix length and/or fallback notice behavior mismatch
'
Scope (this repo)
ext/standard temp file logic (prefix truncation, path validation)
- VM error reporting: Notice emission parity for fallback
- Compliance PHPT(s) ported from php-src (focus on prefix length + invalid dir fallback)
Done when
Category
stdlibProblem
tempnam()has several php-src-specific behaviors that should match Zend:$directoryfalls back to system temp dir and emits a Noticephp-src reference
main/php_open_temporary_file.ctempnam()implementation:ext/standard/file.cext/standard/tests/file/tempnam_variation9.phpt(prefix max length)ext/standard/tests/file/tempnam_variation7-win32.phpt(invalid/non-existing dir fallback behavior)ext/standard/tests/file/tempnam_variation4.phpt(null byte handling)Repro
Save as
repro_tempnam_prefix_fallback.php:Run in Docker:
Scope (this repo)
ext/standardtemp file logic (prefix truncation, path validation)Done when
repro_tempnam_prefix_fallback.phpmatches Zend under./phpc run./script/ci-fast.sh --filter VMTestpasses for the added tests