Opened 4 years ago
Closed 4 years ago
#50666 closed defect (bug) (fixed)
Size limit not correctly applied for sitemaps index
Reported by: | swissspidy | Owned by: | swissspidy |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | 5.5 |
Component: | Sitemaps | Keywords: | has-patch has-unit-tests commit |
Focuses: | Cc: |
Description
Sitemaps have a few size restrictions:
- each Sitemap file that you provide must have no more than 50,000 URLs
- Sitemap index files may not list more than 50,000 Sitemaps
The latter is seemingly enforced in \WP_Sitemaps_Registry::get_sitemaps()
, but actually this method only limits the number of sitemap providers, not the amount of sitemaps all providers add to the index in total.
Thus, this logic needs to be moved to \WP_Sitemaps_Index::get_sitemap_list()
Attachments (2)
Change History (8)
This ticket was mentioned in Slack in #core-sitemaps by swissspidy. View the logs.
4 years ago
#4
@
4 years ago
50666.2.diff is the same as 50666.diff except for:
WP_Sitemaps_Index::get_sitemap_list()
: break out of the loop as soon ascount( $sitemaps ) >= $this->max_sitemaps
- the new unit test is more explict about what it is testing
- as part of that, the constructor for the new
WP_Sitemaps_Large_Test_Provider
class takes a parameter for how many entries the test provider should generate - this new parameter may also be useful in future uses of this test provider
- as part of that, the constructor for the new
Note: See
TracTickets for help on using
tickets.
50666.diff works as expected, and all tests pass (existing and the new one).
However, I'd suggest one change to
WP_Sitemaps_Index::get_sitemap_list()
: for efficiency, break out of the loop as soon ascount( $sitemaps ) >= $this->max_sitemaps
, no need to have all providers generate entries if the max has already been reached.I'd also structure the new test a little differently.
Updated patch coming shortly.