Skip to content

Conversation

@ndossche
Copy link
Member

The notice was outputted before the creation of the file even took place. Therefore, if the creation of the file fails, the notice is outputted while it shouldn't have been.
This changes one test which indeed suffered from this issue due to the open_basedir restriction.

The notice was outputted before the creation of the file even took
place. Therefore, if the creation of the file fails, the notice is
outputted while it shouldn't have been.
This changes one test which indeed suffered from this issue due to the
open_basedir restriction.
@ndossche ndossche requested a review from bukka as a code owner October 16, 2025 19:55
@ndossche ndossche linked an issue Oct 16, 2025 that may be closed by this pull request
The function returned false, this should've never been outputted in the
first place.
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

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should change the text completely (even for successful fallback creation) because some people can ignore error message by text in error handler (I saw that in some legacy code in past) so we don't want to break that (or more minimise chance of breaking it) if the target is 8.3. But different message in that TODO bit would make sense.

Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

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

The fix makes sense except maybe that TODO bit...

Comment on lines +309 to +311
if (UNEXPECTED(fd == -1)) {
/* TODO: decide whether we should notice that even the fallback failed? */
} else {
Copy link
Member

Choose a reason for hiding this comment

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

I just checked and all callers trigger their own warning if the function fails so I think you should remove this TODO. Also if we really wanted such warning / notice, it should happen for non fallback as well...

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see what you meant of keep that message after reading Tim's comment. I guess maybe that makes sense to add a noticed so people don't get confused actually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tempnam notice message incorrect

3 participants