WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. lukewarmmizer
    Member
    Posted 2 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;
    	$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/

  2. lukewarmmizer
    Member
    Posted 2 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
    Member
    Plugin Author

    Posted 2 years ago #

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

  4. itthinx
    Member
    Plugin Author

    Posted 1 year ago #

    Release 2.1.5 fixes this.

    Many thanks again lukewarmmizer for reporting this issue.

  5. lukewarmmizer
    Member
    Posted 1 year 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

About this Topic

Tags

No tags yet.