Automattic / msm-sitemap

Comprehensive sitemaps for your WordPress VIP site. Joint collaboration between Metro.co.uk, WordPress VIP, Alley Interactive, Maker Media, 10up, and others.
74 stars 37 forks source link

fixes #162, Conflicts with Wordpress 5.5 Sitemaps #163

Open rodruiz opened 4 years ago

rodruiz commented 4 years ago

Because Wordpress 5.5 is using the query var "sitemap" to generate the "wp-sitemap.xml" file there is a conflict with this plugin. Both are using the same query var.

This PR is updating the query var to "sitemap_msm".

Fixes #162. Should fix https://core.trac.wordpress.org/ticket/51136

rodruiz commented 4 years ago

When you merge this PR you can create a tag "1.5.0" to match the new plugin version?

Thanks.

mehigh commented 3 years ago

The bug in core is still existing - https://core.trac.wordpress.org/ticket/51136 Can this get merged any time soon?

rodruiz commented 3 years ago

Have been using this patch in production and everything is working as expected.

vaurdan commented 3 years ago

Hey @rodruiz, thank you for submitting the PR! This solution seems to be a good fix, however, for compatibility reasons, changing the query var would bring some issues. For example, I tested this on a VIP Go environment, and it requires flushing the rewrite rules, otherwise example.com/sitemap.xml will start showing WordPress's 404 page.

Since this would impact sites that aren't experiencing this issue, we believe that changing the query var is too risky. I believe the best path forward is to try to have the core bug patched, and in the meantime have the workaround in #161 merged, as it will not affect the sites that aren't experiencing this bug.

rodruiz commented 11 months ago

Have been using this patch in production for years (on VIP Go environments) and everything is working as expected.

@vaurdan yes, flushing the rewrite rules is required when you install and uninstall this plugin. On new installs, a site admin needs to manually flush the rewrites before use anyway.

Option 1: We can add an activation and deactivation hook to flush rewrite rules. Preferred.

Option 2: Check when the plugin loads and flush rewrite rules automatically.

function msm_sitemap_check_rewrite_rules() {
    if ( ! get_option( 'msm_sitemap_check_rewrite_rules', false ) ) {
        update_option( 'msm_sitemap_check_rewrite_rules', true );
        flush_rewrite_rules();
    }
}
add_action( 'plugins_loaded', 'msm_sitemap_check_rewrite_rules' );