WordPress.org

Make WordPress Core

Ticket #22900: hotfix.22900.diff

File hotfix.22900.diff, 2.7 KB (added by dd32, 2 years ago)

Avoid error condition on IIS7 via Hotfix plugin

  • hotfix.php

     
    3535 
    3636        switch ( $wp_version ) { 
    3737                case '3.5' : 
    38                         $hotfixes = array( '350_twentytwelve' ); 
     38                        $hotfixes = array( '350_twentytwelve', '350_iis_http_failure' ); 
    3939                        break; 
    4040                case '3.4.2' : 
    4141                        $hotfixes = array( '342_custom_fields' ); 
     
    217217        return wp_remote_post( $url, $args ); 
    218218} 
    219219 
     220function wp_hotfix_350_iis_http_failure() { 
     221        add_action( 'pre_http_request', 'wp_hotfix_350_iis_http_failure_pre_http_request', 10, 3 ); 
     222} 
     223 
     224function wp_hotfix_350_iis_http_failure_pre_http_request( $return, $args, $url ) { 
     225        if ( ! $args['stream'] ) 
     226                return $return; 
     227        if ( $args['filename'] && @is_writable( dirname( $args['filename'] ) ) ) 
     228                return $return; 
     229 
     230        $filename = $args['filename'] ? basename( $args['filename'] ) : basename( $url ); 
     231 
     232        $temp_dir = wp_hotfix_350_iis_http_failure_get_temp_dir(); 
     233        if ( ! $temp_dir ) 
     234                return new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) ); // Core string 
     235 
     236        $args['filename'] = $temp_dir . $filename; 
     237 
     238        return wp_remote_request( $url, $args ); 
     239} 
     240 
     241function wp_hotfix_350_iis_http_failure_get_temp_dir() { 
     242        $temp = ini_get('upload_tmp_dir'); 
     243        if ( is_dir( $temp ) && @is_writable( $temp ) ) 
     244                return trailingslashit( rtrim( $temp, '\\' ) ); 
     245 
     246        $temp = WP_CONTENT_DIR . '/'; 
     247        if ( is_dir( $temp ) && @is_writable( $temp ) ) 
     248                return $temp; 
     249        return false; 
     250} 
     251 No newline at end of file 
  • readme.txt

     
    1515 
    1616* **WordPress 3.5** 
    1717        * Lets you update Twenty Twelve if it is shown as "broken" after installing 3.5 
     18        * Lets you update WordPress, or, install/update Themes, and Plugins on IIS7 under certain conditions 
    1819 
    1920* **WordPress 3.4.2** 
    2021        * Fix adding and updating Custom Fields 
     
    3435Read the "Complete Hotfix List" section in the description. A later version of the plugin may list the hotfixes in a special WordPress admin page. 
    3536 
    3637== Changelog == 
     38= 1.1 = 
     39* Lets you update WordPress, or, install/update Themes, and Plugins on IIS7 under certain conditions 
     40 
    3741= 1.0 = 
    3842* Lets you update Twenty Twelve if it is shown as "broken" after installing 3.5 
    3943 
     
    9397== Complete Hotfix List == 
    9498* **WordPress 3.5** 
    9599        * Lets you update Twenty Twelve if it is shown as "broken" after installing 3.5 
     100        * Lets you update WordPress, or, install/update Themes, and Plugins on IIS7 under certain conditions 
    96101 
    97102* **WordPress 3.4.2** 
    98103        * Fix adding and updating Custom Fields