Problem/Motivation

\Drupal\Component\FileSystem\FileSystem::getOsTemporaryDirectory() looks for a temp directory in the following order:

  1. ini_get('upload_tmp_dir');
  2. (if windows) 'c:\\windows\\temp'
  3. (if windows) 'c:\\winnt\\temp'
  4. '/tmp'
  5. sys_get_temp_dir()

Locally for me this means I use /tmp and not the secure temp directory my php has at /var/folders/6r/j46s2lv14rn97ghzlk4k18d80000gn/T

Proposed resolution

Change the order to

  1. ini_get('upload_tmp_dir');
  2. sys_get_temp_dir()
  3. (if windows) 'c:\\windows\\temp'
  4. (if windows) 'c:\\winnt\\temp'
  5. '/tmp'

Remaining tasks

User interface changes

None

Introduced terminology

N/a

API changes

None

Data model changes

None

Release notes snippet

Issue fork drupal-3586645

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review

andypost’s picture

Status: Needs review » Reviewed & tested by the community

I think no tests required for that, OTOH maybe CR required and probably we can get rid of hardcoded paths in follow-up like remove hardcoded path for win/linux

nicxvan’s picture

A CR is probably necessary reading the comments on https://www.php.net/manual/en/function.sys-get-temp-dir.php

A lot of them are very old so I'm not sure they are relevant to current php versions.

alexpott’s picture

I've created a CR - I'm not 100% convinced by the utility as this is going to be very opaque to most but there's no harm.

nicxvan’s picture

Looks good to me.

I think it's useful since it can change where to check if you're debugging something.

  • amateescu committed 64bdb28c on 11.x
    task: #3586645 Change order of directories in \Drupal\Component\...

  • amateescu committed 7e696692 on main
    task: #3586645 Change order of directories in \Drupal\Component\...
amateescu’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 7e69669 to main and 64bdb28 to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.