-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Filesystem] Add $suffix argument to tempnam() #33003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the reviews. I have made the suggested changes. |
The test failures on Travis seem to be related to your changes. |
Thanks. I fixed my code/tests so they are passing again. Travis is now failing for reasons that appear to be unrelated to this PR. |
@jdufresne is your current branch up to date with 4.4? |
The parent commit is d3a7be8 (a few new commits landed minutes ago). Looks like the 4.4 branch is also failing with the same errors as of today. |
The test failures have been caused by Twig. The issue should be fixed with twigphp/Twig@debc5c3 |
Thanks for the review! I've followed the linked example by dropping the argument and using the shim. |
I'm divided about this proposal. The But, adding a suffix should always be simple because it's safe to append a string to the value returned by this function. So, I'd probably close this as "won't fix". However, another option would be to change the current "prefix" option to be a "pattern" option with only one placeholder called // Before
$fs->tempnam('/tmp', 'prefix_');
$fs->tempnam('/tmp', 'prefix_', '.png');
// After
$fs->tempnam('/tmp', 'prefix_{filename}');
$fs->tempnam('/tmp', 'prefix_{filename}.png'); |
The prefix is actually a required parameter in the native
The problem here is that you will then manually need to create the file and remove the original file (as the method creates the file as well and doesn't just return a path). So going from
to this
|
@pierredup you explained it well. I think I'm now a bit more 👍 about this proposal. |
I've made the suggested change from @stof and dropped the deprecation warning so that |
Thanks. I understand now. I have applied the suggested patch in the latest revision. |
fabbot is suggesting that I should remove |
I would say its a false/positive |
Thanks. At this stage is there anything I should do to move this PR forward? |
Thank you @jdufresne. |
Description
The
tempnam()
interface was previously:This adds a third argument,
$suffix
, that is appended to the filename after the random component. This defaults to''
for backwards compatibility. This is quite useful when the temporary file is consumed for a specific purpose that expects a suffix.Example
Would create a file like:
/tmp/prefix_abcd1234.png
.