WordPress.org

Make WordPress Core

Ticket #37380: 37380.2.patch

File 37380.2.patch, 2.3 KB (added by Clorith, 5 years ago)

Moves a larger block up as $write and $update_required also need to be available sooner

  • src/wp-admin/options-permalink.php

     
    6666        $blog_prefix = '/blog';
    6767}
    6868
     69$category_base       = get_option( 'category_base' );
     70$tag_base            = get_option( 'tag_base' );
     71$update_required     = false;
     72
     73if ( $iis7_permalinks ) {
     74        if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') )
     75                $writable = true;
     76        else
     77                $writable = false;
     78} elseif ( $is_nginx ) {
     79        $writable = false;
     80} else {
     81        if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) {
     82                $writable = true;
     83        } else {
     84                $writable = false;
     85                $existing_rules  = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) );
     86                $new_rules       = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) );
     87                $update_required = ( $new_rules !== $existing_rules );
     88        }
     89}
     90
     91$usingpi = $wp_rewrite->using_index_permalinks();
     92
    6993if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
    7094        check_admin_referer('update-permalink');
    7195
     
    123147        wp_redirect( admin_url( 'options-permalink.php?settings-updated=true' ) );
    124148        exit;
    125149}
    126 
    127 $category_base       = get_option( 'category_base' );
    128 $tag_base            = get_option( 'tag_base' );
    129 $update_required     = false;
    130 
    131 if ( $iis7_permalinks ) {
    132         if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') )
    133                 $writable = true;
    134         else
    135                 $writable = false;
    136 } elseif ( $is_nginx ) {
    137         $writable = false;
    138 } else {
    139         if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) {
    140                 $writable = true;
    141         } else {
    142                 $writable = false;
    143                 $existing_rules  = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) );
    144                 $new_rules       = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) );
    145                 $update_required = ( $new_rules !== $existing_rules );
    146         }
    147 }
    148 
    149 $usingpi = $wp_rewrite->using_index_permalinks();
    150150
    151151flush_rewrite_rules();
    152152