flush_rewrite_rules is called on every page load
-
The script
/pwa-for-wp/service-work/class-service-worker.php
has a methodpwaforwp_onesignal_rewrite
which is called every time a page is loaded. This results in rewriting the.htaccess
file contents to disk. This is bad behavior and also results in errors when used in combination with WPML. For some reason, WPML adds the language to the RewriteBase, resulting in a duplicate Rewrite block. This is a known bug when plugins update the .htaccess file too often.Also, the code for the method seems wrong:
function pwaforwp_onesignal_rewrite(){ flush_rewrite_rules(); // Flushing rewrite urls ONLY on activation global $wp_rewrite; $wp_rewrite->flush_rules(); add_rewrite_rule("onesignal_js/([0-9]{1,})?$", 'index.php?'.pwaforwp_query_var('sw_query_var').'=1&'.pwaforwp_query_var('sw_file_var').'='.'dynamic_onesignal'."&".pwaforwp_query_var('site_id_var').'=$matches[1]',> add_rewrite_rule("onesignal_js/?$", 'index.php?'.pwaforwp_query_var('sw_query_var').'=1&'.pwaforwp_query_var('sw_file_var').'='.'dynamic_onesignal'."&".pwaforwp_query_var('site_id_var').'=normal', 'top'); }
Calling the method
flush_rewrite_rules
already calls$wp_rewrite->flush_rules();
, so this code seems to do it twice!The
pwaforwp_pushnami_rewrite
method has the same behavior, but adding this method to the init hook is disabled by an option, so it’s not triggered by default.
- The topic ‘flush_rewrite_rules is called on every page load’ is closed to new replies.