Also, are you using wp-cli to flush the rewrite rules?
Another thing that comes to my mind is a too clever for its own good kind of plugin doing its rewrite rules dynamically by looking at $_SERVER values or something which wouldn’t be properly populated when running in CLI mode.
]]>However, if I flush rewrites and while it’s processing the rewrites and another request comes in, it passes that conditional before the update_option happens, it will write it’s own rewrites.
Here’s my gist for the solution
https://gist.github.com/andyphillips82/9bd0cdab46dd01638181693343e08c72
Only flush_rewrites should update the rewrite rules, parse request should only get them.
]]>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.