• Resolved internetbureau

    (@internetbureau)


    The script /pwa-for-wp/service-work/class-service-worker.php has a method pwaforwp_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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Magazine3

    (@magazine3)

    Sorry for the inconvenience. Can you please share the URL of the site once?

    Thread Starter internetbureau

    (@internetbureau)

    Unfortunately, the site is still in devleopment and not open for the public. Also, we’ve already ‘fixed’ the issue by applying this change to the code: https://github.com/ahmedkaludi/pwa-for-wp/issues/765

    It would be great if the mentioned workaround could be applied to the upstream code, so we can at least disabe the flushes when we are not using One Signal.

    Plugin Author Magazine3

    (@magazine3)

    Unfortunately, the site is still in devleopment and not open for the public— Okay, Once it’s available then please share it with us, So that we will go through it.

    Also, we’ve already ‘fixed’ the issue by applying this change to the code — Glad to hear and We will look into it definitely and update you if there is any workaround.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘flush_rewrite_rules is called on every page load’ is closed to new replies.