Make WordPress Core

Opened 7 months ago

Closed 5 months ago

Last modified 5 months ago

#63711 closed enhancement (fixed)

Adopt standard get_temp_dir() in Text_Diff

Reported by: timotijhof's profile TimoTijhof Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.9 Priority: normal
Severity: minor Version: 6.9
Component: External Libraries Keywords: has-patch
Focuses: Cc:

Description

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

Change History (6)

#1 @TimoTijhof
7 months ago

Related:

I note that it appears to be impossible to use this code in practice because "auto" chooses between the faster php-xdiff extension and fallback/native PHP code. To use it, one would need to use new Text_Diff('shell') or construct the Text_Diff_Engine_shell class directly. Are these two classes considered a public stable API for plugin/theme authors? If not, I could instead remove that part of it.

Last edited 5 months ago by SergeyBiryukov (previous) (diff)

This ticket was mentioned in PR #9276 on WordPress/wordpress-develop by @TimoTijhof.


7 months ago
#2

  • Keywords has-patch added

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 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]: https://github.com/horde/Text_Diff/commit/323c4783b9
[2]: https://github.com/horde/Text_Diff/commit/152f6aacf8
[3]: https://github.com/horde/Util/blob/v2.5.12/lib/Horde/Util.php#L200

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

#3 @SergeyBiryukov
5 months ago

  • Milestone changed from Awaiting Review to 6.9
  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

#4 @SergeyBiryukov
5 months ago

In 60776:

Docs: Clarify the description for get_temp_dir().

Includes a note that sys_get_temp_dir() honors the TMPDIR environment variable.

Follow-up to [17555], [22008], [28936].

Props TimoTijhof, SergeyBiryukov.
See #63711.

#5 @SergeyBiryukov
5 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 60777:

External Libraries: Adopt standard get_temp_dir() in Text_Diff::_getTempDir().

This aims to bring more consistency with the rest of core, and more closely mirrors the similar changes upstream to use sys_get_temp_dir().

The potential false return value was not checked by the only caller in Text_Diff_Engine_shell::diff().

Follow-up to [7747], [48464], [49185], [60776].

Props TimoTijhof, apermo, SergeyBiryukov.
Fixes #63711.

#6 @TimoTijhof
5 months ago

@SergeyBiryukov Thank you!

Note: See TracTickets for help on using tickets.