Hi internals,
As a follow-up on my previous message here
(https://marc.info/?l=php-internals&m=168912164828942&w=2),
I would like to start the discussion on the "Support optional suffix
parameter in tempnam" RFC.
https://wiki.php.net/rfc/tempnam-suffix-v2
The goal is, as suggested by its title, to allow an optional parameter
to the tempnam function, which would set a suffix to the created
temporary file.
This is a take-over on a previous attempt by Stefan Neufeind
(https://wiki.php.net/rfc/tempnam-suffix), who I am Ccing for
visibility.
I left some of my concerns regarding the proposed implementation in the
open issues section along with arguments for leaving them as is.
Provided no suggestions/discussions arrise from them, I will move them
to the future scope section before starting the voting phase for this
change.
Thanks in advance for any feedback here.
regards,
--
Athos Ribeiro
Le mardi 8 août 2023, 21:11:01 CEST Athos Ribeiro a écrit :
Hi internals,
As a follow-up on my previous message here
(https://marc.info/?l=php-internals&m=168912164828942&w=2),
I would like to start the discussion on the "Support optional suffix
parameter in tempnam" RFC.
https://wiki.php.net/rfc/tempnam-suffix-v2
Hello,
The RFC does not explain what benefits brings using tempnam($directory, $prefix, $suffix) over using tempnam($directory, $prefix).$suffix , which you can already use?
Côme
Hi
The RFC does not explain what benefits brings using tempnam($directory, $prefix, $suffix) over using tempnam($directory, $prefix).$suffix , which you can already use?
As per the documentation of tempnam:
Creates a file with a unique filename, with access permission set to 0600, in the specified directory.
The function does not just generate a filename, but also creates the
file itself (with strict permissions) to "reserve" it and thus
guarantees that there won't be a conflict. Manually appending a suffix
does not have that property [1].
Best regards
Tim Düsterhus
[1] Though I'd like to note that using $prefix . bin2hex(random_bytes(16)) . $suffix
as the filename will almost
certainly [2] give you a conflict-free filename and doesn't have
OS-specific behavior. That's why I personally don't bother with tempnam()
.
[2] Collision chance is less than 10^(-7) for 2^52 files.
Le mardi 8 août 2023, 21:11:01 CEST Athos Ribeiro a écrit :
Hi internals,
As a follow-up on my previous message here
(https://marc.info/?l=php-internals&m=168912164828942&w=2),
I would like to start the discussion on the "Support optional suffix
parameter in tempnam" RFC.
https://wiki.php.net/rfc/tempnam-suffix-v2Hello,
The RFC does not explain what benefits brings using tempnam($directory, $prefix, $suffix) over using tempnam($directory, $prefix).$suffix , which you can already use?
Côme
Hi Côme,
Thanks for the input and for going through the proposal.
As the tempnam short description
(https://www.php.net/manual/en/function.tempnam.php) states
tempnam — Create file with unique file name
So tempnam
-
creates a file with specific permissions in a given path
($directory); and -
returns the full path of the created file on success.
For the sole purpose of obtaining a file path (2), I see no reasons for
not using "tempnam($directory, $prefix).$suffix" as you suggested.
However, to create the temporary file (1) allowing appending a suffix
string to the created file, we would need to change tempnam. This is the
purpose of this RFC.
In other words, although the return value of "tempnam($directory,
$prefix).$suffix" and the proposed "tempnam($directory, $prefix,
$suffix)" may be the same, the outcome of running each of those, is
not.
The second paragraph of the RFC introduction says
"It would be useful to allow users to also specify a suffix when
generating temporary files. [...]"
Do you have any suggestions on how we could improve the RFC introduction
text to make this clearer to readers of this RFC?
--
Athos Ribeiro
I would like to start the discussion on the "Support optional suffix
parameter in tempnam" RFC.
https://wiki.php.net/rfc/tempnam-suffix-v2
Hi,
As per item 6 at https://wiki.php.net/rfc/howto#how_to_create_an_rfc,
this is a heads up to announce I am moving this to the voting phase
tomorrow.
--
Athos Ribeiro