Use \Drupal\Core\File\FileSystemInterface::getTempDirectory() instead of sys_get_temp_dir() where possible

Created on 27 July 2021, about 3 years ago
Updated 8 March 2023, over 1 year ago

Problem/Motivation

In #3063704-20: Deprecate \Drupal\Component\FileSystem\FileSystem::getOsTemporaryDirectory() and replace with sys_get_temp_dir() I found that tests using OS temporary directory instead of one defined by file_system service.
It may cause to use /tmp even if settings.php overrides it (it possible that OS does not allow to use common directory - systemd PrivateTmp=true)

Proposed resolution

Use \Drupal\Core\File\FileSystemInterface::getTempDirectory() inside of tests

Remaining tasks

agree, patch, commit

User interface changes

no

API changes

no

Data model changes

no

Release notes snippet

no

📌 Task
Status

Needs work

Version

10.1

Component
Base 

Last updated 30 minutes ago

Created by

🇫🇷France andypost

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • First commit to issue fork.
  • @bhanu951 opened merge request.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Bhanu951

    Rerolled #4 against 10.1.x and raised MR.

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    MR has failures it seems

  • 🇮🇳India Bhanu951

    Seems Random test failures. Re-initiated Tests.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Bhanu951

    Back to need review after tests green.

  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

    Change looks good now.

  • Status changed to Needs work over 1 year ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Not sure that we can change only one call in \Drupal\KernelTests\Core\Theme\TwigEnvironmentTest - if they do return different values (which is possible) then the test will fail.

    I'm not convinced that this issue is worth it - we have calls to sys_get_temp_dir() in unit tests that cannot be replaced here so I think we have an expectation that for testing sys_get_temp_dir() works and is writeable.

Production build 0.71.5 2024