Make WordPress Core

Changeset 38751


Ignore:
Timestamp:
10/07/2016 07:43:57 PM (8 years ago)
Author:
jorbin
Message:

Make sure rewrite rules are not written until wp_loaded has fired

If a plugin attempts to change the rewrite rules to early, other plugins may have their rules inadvertently discarded. Additionally, some function such as url_to_post_id cause a rewrite rule lookup that could cause this accidental flushing. This forces the flushing to only occur once wp_loaded has been fired.

Fixes #37892.
Props Chouby.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-rewrite.php

    r38307 r38751  
    14761476            $this->matches = 'matches';
    14771477            $this->rewrite_rules();
     1478            if ( ! did_action( 'wp_loaded' ) ) {
     1479                add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
     1480                return $this->rules;
     1481            }
    14781482            update_option('rewrite_rules', $this->rules);
    14791483        }
Note: See TracChangeset for help on using the changeset viewer.