Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometime a sitemap contains more than $maxUrls URLs #81

Open
DarkSilence opened this issue Jan 10, 2022 · 2 comments
Open

Sometime a sitemap contains more than $maxUrls URLs #81

DarkSilence opened this issue Jan 10, 2022 · 2 comments
Labels

Comments

@DarkSilence
Copy link

The problem lays in flush() function.

When a sitemap is truncated by size here:

if ($this->byteCount + $dataSize + $footSize > $this->maxBytes) {

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):

$this->writerBackend->append($data);

Those URLs in that chunk aren't counted anywhere and a next sitemap overflows.

@DarkSilence
Copy link
Author

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.

@samdark
Copy link
Owner

samdark commented Jan 10, 2022

@DarkSilence would you please convert that sample into unit test? That way we'll be sure it won't be broken again ever.

@samdark samdark added the bug label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants