Skip to content

65651 functions get temp dir - #12566

Open
pbearne wants to merge 8 commits into
WordPress:trunkfrom
pbearne:65651-functions-get_temp_dir
Open

pbearne wants to merge 8 commits into
WordPress:trunkfrom
pbearne:65651-functions-get_temp_dir

Conversation

@pbearne

@pbearne pbearne commented Jul 16, 2026

Copy link
Copy Markdown

This PR adds dedicated unit tests for the get_temp_dir() function in wp-includes/functions.php.
The tests ensure that:
•The function returns a path with a trailing slash as expected by its consumers.
•The returned path is an existing, writable directory.
•The WP_TEMP_DIR constant is correctly respected when defined.

To accurately test the constant behaviour without affecting other tests or being affected by the function's internal static cache, @runInSeparateProcess is utilized for the constant-specific test case.

Trac ticket: https://core.trac.wordpress.org/ticket/65651

AI Disclosure:
•AI assistance: Yes
•Tool(s): Junie (JetBrains)
•Model(s): gemini-3-flash-preview
•Used for: Code analysis, test implementation, and workflow management.

@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props pbearne.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The WP_TEMP_DIR override test uses an already slash-terminated path on non-Windows systems, so it cannot detect whether that branch fails to add the required trailing slash.

1 open issue
What changed in this PR

Adds dedicated PHPUnit coverage for WordPress’s get_temp_dir() function, without changing production behavior.

Changes:

  • Checks that the returned path has a trailing slash and identifies an existing, writable directory.
  • Verifies that WP_TEMP_DIR is respected, using a separate process to isolate the constant definition.
File Description
tests/​phpunit/​tests/​wp-includes/​functions/​GetTempDirTest.php Adds three tests covering temporary-directory behavior and the constant override.

Review effort: Balanced

pbearne and others added 2 commits November 4, 2026 18:21
Remove trailing slashes from custom temp directory paths.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the added PHPUnit coverage for get_temp_dir().

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@pbearne
pbearne requested a review from lancewillett November 5, 2026 17:47

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With WP_TEMP_DIR already set in the PHPUnit configuration, test_get_temp_dir_respects_constant() errors with “Constant WP_TEMP_DIR already defined” before it reaches its assertion. Running in a separate process still loads that configuration. Please define the custom path only when the constant is absent, then assert against trailingslashit( WP_TEMP_DIR ). I verified that version with and without a configured override. The override is a path supplied by the site, so its writability isn’t guaranteed by this function.

AI review · gpt-6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants