[wp-trac] [WordPress Trac] #50910: 5.5 Sitemap URLs are incorrectly paginated

WordPress Trac noreply at wordpress.org
Mon Aug 17 01:32:13 UTC 2020


#50910: 5.5 Sitemap URLs are incorrectly paginated
--------------------------------------+-----------------------------
 Reporter:  jonathanstegall           |       Owner:  SergeyBiryukov
     Type:  defect (bug)              |      Status:  accepted
 Priority:  normal                    |   Milestone:  5.5.1
Component:  Sitemaps                  |     Version:  5.5
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+-----------------------------

Comment (by pbiron):

 I'm not sure why, but I'm now seeing the behavior described...and I wasn't
 before.

 [attachment:"50910.diff"] solves the problem is essentially the same was
 as the PR from @peterwilsoncc (by ensuring that `redirect_canonical()`
 doesn't incorrectly add `page/2`), but does so in a simpler way.

 The patch introduces a new function, `get_sitemap_url()` that is similar
 in spirit to `get_permalink()` but for sitemap URLs and uses that in
 `redirect_canonical()`.

 Not only does that make `redirect_canonical()` easier to follow when
 dealing with sitemap canonicals compared to Peter's PR, but it "future
 proofs" things as well. Peter's PR in essence bakes the structure of
 sitemap canonical URLs into `redirect_canonical()`.  Since
 `WP_Sitemap_Provider` has a `get_sitemap_url()` method, having that
 structure baked into `redirect_canonical()` could cause problems down the
 road should `WP_Sitemaps_Provider::get_sitemap_url()` change the structure
 of the URLs (however unlikely such a future change may be).  The new
 `get_sitemap_url()` function uses
 `WP_Sitemaps_Provider::get_sitemap_url()`.

 The patch also moves Peter's unit test into the file with the existing
 sitemaps canonical tests: `tests/canonical/sitemaps.php` (and uses a data
 provider to make it easier, IMO, to add additional test cases).

 Additionally, the patch adds unit tests for the new `get_sitemaps_url()`
 function.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50910#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list