From d5ba63e6a5efc1d597f1c165697f03fde15b7e29 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 16 Jul 2016 12:43:16 +0000 Subject: [PATCH] Permalinks: After [37747], make sure `$usingpi`, `$writable`, and `$update_required` are defined before checking them on permalinks update. Props Clorith. Fixes #37380. git-svn-id: https://develop.svn.wordpress.org/trunk@38066 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/options-permalink.php | 48 +++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/wp-admin/options-permalink.php b/src/wp-admin/options-permalink.php index 224e2224ce..978ffacd22 100644 --- a/src/wp-admin/options-permalink.php +++ b/src/wp-admin/options-permalink.php @@ -66,6 +66,30 @@ if ( is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpo $blog_prefix = '/blog'; } +$category_base = get_option( 'category_base' ); +$tag_base = get_option( 'tag_base' ); +$update_required = false; + +if ( $iis7_permalinks ) { + if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') ) + $writable = true; + else + $writable = false; +} elseif ( $is_nginx ) { + $writable = false; +} else { + if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) { + $writable = true; + } else { + $writable = false; + $existing_rules = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) ); + $new_rules = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) ); + $update_required = ( $new_rules !== $existing_rules ); + } +} + +$usingpi = $wp_rewrite->using_index_permalinks(); + if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) { check_admin_referer('update-permalink'); @@ -124,30 +148,6 @@ if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) { exit; } -$category_base = get_option( 'category_base' ); -$tag_base = get_option( 'tag_base' ); -$update_required = false; - -if ( $iis7_permalinks ) { - if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') ) - $writable = true; - else - $writable = false; -} elseif ( $is_nginx ) { - $writable = false; -} else { - if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) { - $writable = true; - } else { - $writable = false; - $existing_rules = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) ); - $new_rules = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) ); - $update_required = ( $new_rules !== $existing_rules ); - } -} - -$usingpi = $wp_rewrite->using_index_permalinks(); - flush_rewrite_rules(); require( ABSPATH . 'wp-admin/admin-header.php' );