Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#22900 closed defect (bug)

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

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 (last modified by ocean90)

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:

This problem may have been exacerbated by #20778.

Change History (2)

#1 @nacin
5 years ago

  • Milestone changed from Awaiting Review to 3.5.1

#2 @ocean90
5 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.