[wp-trac] [WordPress Trac] #48199: Check for whether the themes directory writable is incorrect when the current theme is symlinked into the theme directory
WordPress Trac
noreply at wordpress.org
Wed Oct 2 21:40:09 UTC 2019
#48199: Check for whether the themes directory writable is incorrect when the
current theme is symlinked into the theme directory
--------------------------+-----------------------------
Reporter: pbiron | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Site Health | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
To test whether the theme directory is
writable,[https://core.trac.wordpress.org/browser/trunk/src/wp-
admin/includes/class-wp-debug-data.php#L322 WP_Debug_Data::debug_data(),
L322] does:
{{{#!php
$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:
{{{#!php
$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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48199>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list