티스토리 수익 글 보기
{{ message }}
Fix Optimization Detective compatibility with WooCommerce when Coming Soon page is served #1565
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When testing WooCommerce, I discovered an unexpected result when attempting to access the Shop page:
In my local testing site, I imported some sample products but didn’t “launch” the store yet, so WooCommerce is attempting to serve the Coming Soon page to a logged-out user. The relevant code is
ComingSoonRequestHandler::handle_template_include()which filterstemplate_includeto conditionally returnnullon FSE themes:This causes a fatal error in Optimization Detective:
This is because
od_buffer_output()is erroneously defined with a strictstringtype for the method parameter. Well, I suppose WooCommerce is also erroneously returningnullwhen it should instead return an empty string (which has the same effect) since thetemplate_includefilter is defined as passing astringand notstring|null.In any case, since we don’t actually do anything with the variable we can just remove the typing. The result is the page as expected: