Sitemap Error
-
Title: PHP Warning on sitemap URLs causes intermittent XML parsing error
Hello,
I’ve been experiencing an intermittent issue with the 10Web Speed Optimizer plugin that I’ve managed to trace back to your code. I’m sharing the full details here hoping it can be fixed in a future release.
Environment
- WordPress with Elementor
- Hosting: OVH (shared hosting)
- Plugins: 10Web Speed Optimizer, RankMath SEO
- PHP debug mode enabled (log only, not displayed)
The problem
Occasionally, when visiting my sitemap URL (e.g. /page-sitemap.xml), the browser displays an XML parsing error instead of the sitemap:
error on line 2 at column 10: XML declaration allowed only at the start of the document
This happens intermittently — not on every request. A simple page refresh fixes it, and it doesn’t happen again for some time. This strongly suggests a caching issue where a corrupted response gets stored.
Root cause identified
After enabling WP_DEBUG_LOG, I found the following warnings being generated at the exact time the sitemap is requested:
[11-Mar-2026 14:35:27 UTC] PHP Warning: Attempt to read property "ID" on null in .../tenweb-speed-optimizer/includes/OptimizerElementor.php on line 85This warning is repeated multiple times per request. The issue is that
OptimizerElementor.phpattempts to access theIDproperty on a$postobject that is null — which is expected behavior on sitemap URLs, since there is no post object associated with them.Even though
WP_DEBUG_DISPLAYis set tofalse, it appears that your caching layer sometimes captures the response at a moment when this warning causes a stray character or newline to be output before the<?xmldeclaration. This pushes the XML declaration to line 2, making the document invalid.Is it possible to remove the cache on:
/sitemap_index.xml
/page-sitemap.xml
/post-sitemap.xml
/category-sitemap.xml
.*-sitemap.xmlThanks for looking into this — happy to provide any additional details if needed.
The page I need help with: [log in to see the link]
You must be logged in to reply to this topic.