[wp-trac] [WordPress Trac] #22900: is_writable function fails on Windows systems causing spurious http_request_failed error

WordPress Trac noreply at wordpress.org
Wed Dec 12 22:26:58 UTC 2012


#22900: is_writable function fails on Windows systems causing spurious
http_request_failed error
--------------------------+--------------------
 Reporter:  Otto42        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  3.5.1
Component:  HTTP          |     Version:  3.5
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+--------------------
Description changed by ocean90:

Old 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.

New 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.

--

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22900#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list