Skip to content
Open
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: 0 additions & 2 deletions ext/standard/tests/file/bug52624.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ echo tempnam("directory_that_not_exists", "prefix_");

?>
--EXPECTF--
Notice: tempnam(): file created in the system's temporary directory in %sbug52624.php on line %d

Warning: tempnam(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s on line %d
2 changes: 0 additions & 2 deletions ext/standard/tests/file/tempnam_variation3-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ OK
-- Iteration 3 --
OK
-- Iteration 4 --

Notice: tempnam(): file created in the system's temporary directory in %stempnam_variation3-win32.php on line %d
Failed, not created in the correct directory %s vs %s
0
-- Iteration 5 --
Expand Down
14 changes: 10 additions & 4 deletions main/php_open_temporary_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,16 @@ PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_strin
if (temp_dir &&
*temp_dir != '\0' &&
(!(flags & PHP_TMP_FILE_OPEN_BASEDIR_CHECK_ON_FALLBACK) || !php_check_open_basedir(temp_dir))) {
return php_do_open_temporary_file(temp_dir, pfx, opened_path_p);
fd = php_do_open_temporary_file(temp_dir, pfx, opened_path_p);
if (!(flags & PHP_TMP_FILE_SILENT) && dir && *dir != '\0') {
/* Default temporary directory fallback. */
if (UNEXPECTED(fd == -1)) {
/* TODO: decide whether we should notice that even the fallback failed? */
} else {
php_error_docref(NULL, E_NOTICE, "file created in the system's temporary directory");
}
}
return fd;
} else {
return -1;
}
Expand All @@ -317,9 +326,6 @@ PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_strin
fd = php_do_open_temporary_file(dir, pfx, opened_path_p);
if (fd == -1) {
/* Use default temporary directory. */
if (!(flags & PHP_TMP_FILE_SILENT)) {
php_error_docref(NULL, E_NOTICE, "file created in the system's temporary directory");
Copy link
Member

@TimWolla TimWolla Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively perhaps just:

file will be created […]

Looking at ext/standard/tests/file/bug52624.phpt folks might otherwise be confused why the final error message mentions /tmp.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. I'm undecided yet, hence also the TODO I put

}
goto def_tmp;
}
return fd;
Expand Down
Loading