|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69489 tempnam() should raise notice if falling back to temp dir
Submitted: 2015-04-20 14:37 UTC Modified: 2016-06-09 21:40 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: Assigned: ab (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.6.8 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2015-04-20 14:37 UTC]
As has been pointed out in bug #55804, tempnam() doesn't explicitly
indicate when it is falling back to the system's temp directory. It
might be appropriate to raise a notice in this case.

Test script:

tempnam('non/existing/directory', 'pre');

Expected result:
A file is created in the system's temp directory, and additionally a
notice is raised:

    Notice: tempnam(): file created in the system's temporary
    directory in ... on line ...

Actual result:
A file is created in the system's temp directory without any


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-20 14:42 UTC]
make sense to me, maybe you can make a PR for that?
 [2015-04-21 14:12 UTC]
okey, a quick patch is:

diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c
index a88c823..439e5e4 100644
--- a/main/php_open_temporary_file.c
+++ b/main/php_open_temporary_file.c
@@ -287,6 +287,7 @@ def_tmp:
 	fd = php_do_open_temporary_file(dir, pfx, opened_path_p);
 	if (fd == -1) {
 		/* Use default temporary directory. */
+		php_error_docref(NULL, E_NOTICE, "file created in the system's temporary directory");
 		goto def_tmp;
 	return fd;

 [2015-04-21 14:13 UTC]
-Status: Open +Status: Analyzed
 [2015-04-21 16:11 UTC]
@laruence: that's also what I came up with in the meantime. :)
However, I don't know what other functionality expect tempnam might
also be affected by this change, because php_open_temporary_fd(_ex)
seems to be part of the public API, and might be used by
extensions. If that is so, the notice might not be desired

Anyhow, the biggest issue with submitting a PR is that the PHP test
suite is not running stable on (my) Windows.
 [2015-05-12 12:02 UTC]
Cant we disable this Notice in extension code (if needed) ?
 [2016-06-09 21:40 UTC]
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: ab
 [2016-06-09 21:40 UTC]
The PR is merged in 7.1.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 00:01:28 2024 UTC