WordPress.org

Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#48199 new defect (bug)

Check for whether the themes directory writable is incorrect when the current theme is symlinked into the theme directory

Reported by: pbiron Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Site Health Keywords: 2nd-opinion
Focuses: Cc:
PR Number:

Description

To test whether the theme directory is writable,WP_Debug_Data::debug_data(), L322 does:

$is_writable_template_directory = wp_is_writable( get_template_directory() . '/..' );

If the current theme exists outside of ABSPATH and is symlink'd into ABSPATH . 'wp-content/themes (which I do for all the bundled themes for all sites on my local dev machine) then what is actually being checked is whether that directory outside of ABSPATH is writable, not whether the theme directory is writable.

Changing that line to:

$is_writable_template_directory = wp_is_writable( dirname( get_template_directory() ) );

correctly tests whether the theme directory is writable.

Additionally, when running on a Windows machine, wp_is_writable() calls win_is_writable(), which creates and then unlinks a tmp file. Because of the directory traversal in the path, the unlink fails when the template directory is a symlink...which leaves the tmp file in the parent directory of the symlink'd theme resides outside of ABSPATH. Changing the argument to wp_is_writable() to use dirname() instead of directory traversal also fixes that problem.

Change History (1)

#1 @pbiron
4 weeks ago

  • Keywords 2nd-opinion added

Can someone check whether the use of directory traversal on a linux box when the current theme is symlink'd is actually checking the writability of the directory outside of ABSPATH as it is on a Windows machine?

Note: See TracTickets for help on using tickets.