Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Bizarre Rewrite Flushing bug...

Discussion in 'Troubleshooting & How-To's' started by AndyWPGuy, Oct 22, 2016.

  1. AndyWPGuy

    New Member

    Joined:
    Oct 22, 2016
    Messages:
    2
    Likes Received:
    0
    So we’re running into a very confusing rewrite issue. Our local, development and staging envs are all fine. Our production environment is the only one having the issue.

    Basically whenever we flush the rewrite rules, it will miss various rules through the system. If we flush it enough times, eventually the situation will resolve itself.

    For example, if the serialized version is a:453. We’ll flush and it will say a:314. so it’s missing a good 140 rewrites. If I flush and flush and flush, and clear Redis a few times, it will eventually go to the correct rewrite count.

    We try upping memory to something ridiculous like 2048M, didn’t work.

    Think it could in any way be traffic related?
     
    #1
  2. AndyWPGuy

    New Member

    Joined:
    Oct 22, 2016
    Messages:
    2
    Likes Received:
    0
    I think I found the issue and I think it's in WP core. Basically, when you flush rewrites, it update_option('rewrite_rules','') and then process to process the rewrite rules in wp_rewrite_rules. However, parse_request hits that function as well in it's lifecycle. SO. If I flush rewrite rules, it deletes the option and start processing. During that time, another page is loaded and parse_request is fired. Flush rewrite rules isn't done it's processing and hasn't updated the options, so parse_request doesn't have rewrite rules and rebuilds them in the wrong context.

    Here is my gisthub
    https://gist.github.com/andyphillips82/9bd0cdab46dd01638181693343e08c72

    Don't update the option to ''
    Pass a paramter from flush_rules to wp_rewrite_rules of true
    Set default to false in wp_rewrites rules
    Only update rewrite rules if that options is true.
     
    #2

Share This Page

Web Hosting