Support » Plugin: Affiliates » [Plugin: Affiliates] Rewrite Rules Deleted/Inserted on every request

  • Resolved lukewarmmizer

    (@lukewarmmizer)


    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;
    	$wp_rewrite->flush_rules();
    }

    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!

    http://wordpress.org/extend/plugins/affiliates/

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Affiliates] Rewrite Rules Deleted/Inserted on every request’ is closed to new replies.