close
Skip to content

External Libraries: Adopt standard get_temp_dir() in Text_Diff#9276

Closed
Krinkle wants to merge 1 commit intoWordPress:trunkfrom
Krinkle:unify-temp-dir
Closed

External Libraries: Adopt standard get_temp_dir() in Text_Diff#9276
Krinkle wants to merge 1 commit intoWordPress:trunkfrom
Krinkle:unify-temp-dir

Conversation

@Krinkle
Copy link
Copy Markdown

@Krinkle Krinkle commented Jul 17, 2025

This was placing files in a potentially different place than the rest of WordPress, and its potential false return value was not checked by the only caller in Text_Diff_Engine_shell.

I considered changing our get_temp_dir implementations to check the additional directories that Text_Diff::_getTempDir considered, but decided against it. The Text_Diff code predates the introduction of sys_get_temp_dir in PHP 5.2, and so likely only checking these to make up for that. The latest upstream version of the code that this is based on, also no longer does this and simply calls sys_get_temp_dir instead. Specifically, it removed _getTempDir in favor of tempnam(null) 1, and later switched to the horde/util package, 2 which uses sys_get_temp_dir. 3

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


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

This is placing files in a potentially different place than the
rest of WordPress, and its potential false return value was not
checked by the only caller in Text_Diff_Engine_shell.

I considered changing our get_temp_dir implementations to check
the additional directories that Text_Diff::_getTempDir considered,
but decided against it. The Text_Diff code predates the introduction
of sys_get_temp_dir in PHP 5.2, and so is checking these to make up
for that. The latest version of the code that this was based on no
longer does this and calls sys_get_temp_dir instead. Specifically, it
removed _getTempDir() in favor of tempnam(null) [1], and later
switched to horde/util, [2] which uses sys_get_temp_dir. [3]

[1]: horde/Text_Diff@323c4783b9
[2]: horde/Text_Diff@152f6aacf8
[3]: https://github.com/horde/Util/blob/v2.5.12/lib/Horde/Util.php#L200
@github-actions
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. You can also manually ask me to refresh this list by adding the props-bot label.

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

Props timotijhof.

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

@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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • 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.

Copy link
Copy Markdown

@apermo apermo left a comment

Choose a reason for hiding this comment

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

LGTM, maybe we could consider to mark _getTempDir() as deprecated altogether? And use suggest to directly use get_temp_dir()

@github-actions
Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 60777
GitHub commit: 8b2ff11

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Sep 17, 2025
@Krinkle Krinkle deleted the unify-temp-dir branch September 17, 2025 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants