Since PHP 5.2.1, PHP exposes the system temporary directory to us. Very handy. My version uses that, and if that's not present then it uses tempnam's capability of falling back to the very same directory, copied from a comment in the manual. I checked the source and it's indeed the very same dir just it was not exposed to userland before. This, IMO, makes the system setting totally unneeded.

Comments

chx’s picture

StatusFileSize
new1.81 KB

Even simpler.

alexanderpas’s picture

uhm... what about bad-configured shared hosting, using /tmp for every account, in combination with race-conditions.

(verry funny if that hoster also hosts adult content on the same server...)

drewish’s picture

Status: Needs review » Needs work

looks pretty good to me. the comments need some work to make them proper sentences. marking as CNW for that alone

i kind of liked the whole foreach (array('TMP', 'TMPDIR', 'TEMP') as $key) { in the original patch but think we should be checking that the directory exists.

i also wonder if we could just call $tempfile = tempnam('', '');...

drewish’s picture

the word is that D7 will be PHP 5.2+... so we might be able to just use sys_get_temp_dir()

chx’s picture

alexender, I doubt that's possible, really. You are already using this dir, dont forget, your uploads to the server land in this dir. It's only Drupal's processsing that happens into another dir which IMO is quite pointless.

I am reluctant to rely on tempnam('' -- who knows what happens on different OSes for empty dirnames... while we are PHP 5.2.0+ we are not PHP 5.2.1+

vietcoop’s picture

StatusFileSize
new2.18 KB

Reroll

sun’s picture

Category: feature » task
Status: Needs work » Needs review
Issue tags: +File API, +API clean-up
StatusFileSize
new2.74 KB

Revamped for stream wrappers.

Status: Needs review » Needs work

The last submitted patch failed testing.

aaron’s picture

Status: Needs work » Needs review
StatusFileSize
new2.28 KB

the reason the test fails is that we're still trying to use that variable_get('file_temporary_path', NULL). this patch passes, but i'm sure there are more optimal means to achieve this.

retester2010’s picture

#9: drupal.file-temp-dir.346258.9.patch queued for re-testing.

damien tournoud’s picture

Status: Needs review » Closed (duplicate)

This is already in. Marking as a duplicate of whatever issue introduced it.