Sometime a sitemap contains more than $maxUrls URLs
Opened this issue · 2 comments
The problem lays in flush() function.
When a sitemap is truncated by size here:
Line 232 in a7ba091
finishFile() functions is called which leads to zeroing urlsCount variable, but right after that a remaining chunk is appended to a file here (with contains up to $bufferSize URLs):
Line 240 in a7ba091
Those URLs in that chunk aren't counted anywhere and a next sitemap overflows.
Here's a sample which reproduces the problem:
https://gist.github.com/DarkSilence/9c2bca943d639aae3ad995d8cf35de60
sitemap_test_4.xml should contain 100 records, but it contains 110 records.
@DarkSilence would you please convert that sample into unit test? That way we'll be sure it won't be broken again ever.