Comment Form ESI duplicates when admin role excluded from optimization
-
Hi LiteSpeed team,
I found a reproducible issue with LiteSpeed Cache for WordPress.
Environment:
- WordPress 6.9.4
- LiteSpeed Cache 7.8.1
- OpenLiteSpeed
- ESI enabled
- Admin Bar ESI enabled
- Logged in as administrator
- Page Optimization -> Tuning -> Role Excludes includes: administrator
Issue:
When the administrator role is excluded from Page Optimization, the comment form is duplicated on posts with comment_form() output.In the page source, the original comment form remains wrapped in:
…
and the ESI-rendered comment form is also inserted after:
If I remove administrator from Page Optimization -> Tuning -> Role Excludes and purge cache, the duplication disappears.
Expected result:
The original wrapped comment form should be removed, leaving only the ESI-rendered comment form.Possible cause:
It looks like when the current role is in optm-exc_roles, LiteSpeed Cache defines LITESPEED_NO_OPTM = true. Then Core::send_headers_force() skips the litespeed_buffer_finalize filter.However, LiteSpeed\GUI::finalize() is hooked to litespeed_buffer_finalize and calls _clean_wrapper(), which removes the “LiteSpeed To Be Removed” blocks.
So ESI still inserts the comment form, but the wrapper cleanup is skipped when optimization is disabled for the current role.
Relevant code:
- src/core.cls.php: LITESPEED_NO_OPTM is set for roles in optm-exc_roles
- src/core.cls.php: litespeed_buffer_finalize is skipped when LITESPEED_NO_OPTM is true
- src/gui.cls.php: GUI::finalize() calls _clean_wrapper()
- src/esi.cls.php: comment form ESI wraps original output with GUI::clean_wrapper_begin/end
It seems the ESI cleanup should still run even when Page Optimization is disabled for a role, since this cleanup is required for ESI output correctness.
Thanks!
You must be logged in to reply to this topic.