# Suggestion: Add optional suffix to tempnam()

- Thread: https://externals.io/message/71071
- Original archive: https://news-web.php.net/php.internals/71071
- Started by Stefan Neufeind on 2014-01-11T19:15:28+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #71071 — Stefan Neufeind — 2014-01-11T19:15:28+00:00

URL: https://externals.io/message/71071#71071

Hi,

I'd like to propose adding an optional $suffix to `tempnam()`. Please find
attached a patch that implements this against current master.

Help with this would be appreciated, especially if I did something
wrong, since it's my first php-src patch.

As you might expect, it can be used like
  echo tempnam('.', 'abc-', '.png');

We discussed the usecase lately in the TYPO3-community where there are
some cases where external tools would like to have a proper suffix for
temporary files. They currently use their own "workaround" to have a
 `tempnam()` with suffix.


Kind regards,
 Stefan

---

## #71075 — Yasuo Ohgaki — 2014-01-11T23:38:17+00:00

URL: https://externals.io/message/71071#71075 · In reply to: #71071

Hi Stefan,



> I'd like to propose adding an optional $suffix to `tempnam()`. Please find
> attached a patch that implements this against current master.
>

It's convenient if you could use github instead of attaching patch.
Could you use github or gist?

Thank you.

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #71100 — johannes@schlueters.de — 2014-01-12T20:40:32+00:00

URL: https://externals.io/message/71071#71100 · In reply to: #71071

> -static int php_do_open_temporary_file(const char *path, const char *pfx, char **opened_path_p TSRMLS_DC)
> +static int php_do_open_temporary_file(const char *path, const char *pfx, char **opened_path_p TSRMLS_DC, const char *suffix)

TSRM should be the last parameter, move your new one in front of it.

> -PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, char **opened_path_p, zend_bool open_basedir_check TSRMLS_DC)
> +PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, char **opened_path_p, zend_bool open_basedir_check TSRMLS_DC, const char *suffix)
 
> -PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC)
> +PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC, const char *suffix)

> -PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC)
> +PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC, const char *suffix)
[...]

These are API changes so it could only be in 5.6.0. Eventually it might
be added if instead of changing APIs new functions might be introduced
and the old ones call the new ones.
(also TSRM should be last last there, too)

Aside for that: A test would be good.

For not loosing it either create a feature request at bugs.php.net or
pull request at github.

johannes

---

## #73672 — Stefan Neufeind — 2014-04-11T22:24:03+00:00

URL: https://externals.io/message/71071#73672

Hi,

I'd like to pick up the original discussion about this patch here again.
There have some updates on the github-pull. Maybe somebody could have a
look into this, please?

https://github.com/php/php-src/pull/575


Kind regards,
 Stefan

---

## #73675 — Ferenc Kovacs — 2014-04-12T06:33:40+00:00

URL: https://externals.io/message/71071#73675 · In reply to: #73672

> Hi,
>
> I'd like to pick up the original discussion about this patch here again.
> There have some updates on the github-pull. Maybe somebody could have a
> look into this, please?
>
> https://github.com/php/php-src/pull/575
>
>
> Kind regards,
>  Stefan
>
> --
> 
> 
>
>
Just to make it clear:
To make it into 5.6.0 the RFC should have been voted and accepted, and the
patch finished and merged before the release of the first beta.
None of that happened in time, so now there is no chance to be in 5.6.0.


-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu
