[resolved] Rewrite Rules Deleted/Inserted on every request (5 posts)

  1. lukewarmmizer
    Posted 4 years ago #

    Hi! I noticed that the rewrite_rules option in the wp_options table was being deleted and inserted on every request, and was eventually able to track it down to the Affiliates plugin.

    It looks like in lib/core/wp-init.php the following code is executed every time wordpress is finished loading, which results in the database delete / insert. These queries can't be cached for obvious reasons, so it was a bit of a performance hit (especially as the rewrite rules can get quite large).

    add_filter( 'wp_loaded', 'affiliates_wp_loaded' );
     * Flushes the rewrite rules.
    function affiliates_wp_loaded() {
    	global $wp_rewrite;

    I just commented it out (with a noticeable performance increase) although I suspect that moving it to a new filter/action that fires when a new affiliate is created would achieve the desired results?

    Thanks for all the work you've put into this!


  2. lukewarmmizer
    Posted 4 years ago #

    Follow up - did this properly by removing the filter in functions.php so that it doesn't affect the plugin directly:

    remove_filter( 'wp_loaded', 'affiliates_wp_loaded' );

  3. itthinx
    Plugin Author

    Posted 4 years ago #

    Hey thanks for commenting on this, I'll check that myself and get back on that.

  4. itthinx
    Plugin Author

    Posted 3 years ago #

    Release 2.1.5 fixes this.

    Many thanks again lukewarmmizer for reporting this issue.

  5. lukewarmmizer
    Posted 3 years ago #

    Finally got the chance to upgrade and all looks great, thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Affiliates
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.