WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#22900 closed defect (bug)

is_writable function fails on Windows systems causing spurious http_request_failed error — at Initial Version

Reported by: Otto42 Owned by:
Milestone: 3.5.1 Priority: normal
Severity: normal Version: 3.5
Component: HTTP API Keywords: has-patch commit
Focuses: Cc:

Description

In class-http.php, in request(), there is a double check to be sure a file is writable using this code:

$r['filename'] = get_temp_dir() . basename( $url );

...

if ( ! is_writable( dirname( $r['filename'] ) ) )
	return new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );

Problem is that is_writable can return false incorrectly on Windows systems, due to a PHP bug:
https://bugs.php.net/bug.php?id=30931

Now, get_temp_dir() already performs an is_writable check on the resulting temp directories, and it uses a win_is_writable() call to work around this problem on Windows systems.

Thus, this secondary check is seemingly unnecessary anyway, anything returned by get_temp_dir() really should be writable.

So either the writable check in class-http.php needs to be made Windows compatible, or removed entirely.

A few reports of the problem on support forums:
http://wordpress.org/support/topic/plugin-upgrades-fail-after-update-to-wp-35?replies=6
http://wordpress.org/support/topic/plugin-update-not-writeable?replies=14
http://wordpress.org/support/topic/download-failed-destination-directory-for-file-streaming-does-not-exist?replies=2

This problem may have been exacerbated by #20778.

Change History (0)

Note: See TracTickets for help on using tickets.