Fix PHP warning for array offset on bool in generate_meta_tags#130
Open
enescala wants to merge 1 commit into
Open
Fix PHP warning for array offset on bool in generate_meta_tags#130enescala wants to merge 1 commit into
enescala wants to merge 1 commit into
Conversation
enescala
force-pushed
the
fix/meta-tags-array-offset-warning
branch
from
March 10, 2026 20:39
d722e31 to
7ef8994
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses PHP warnings in the Sailthru Horizon meta tag generation path by fixing post ID usage and safely handling missing attachment image data in generate_meta_tags().
Changes:
- Replace
$post->IDwith$post_object->IDwhen fetching the post thumbnail ID. - Guard accesses to
wp_get_attachment_image_src()results withis_array()checks to avoid array-offset-on-bool warnings.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use $post_object->ID instead of $post->ID for consistency with the rest of the method - Add is_array() checks on wp_get_attachment_image_src() return values before accessing array offsets - Store get_post_thumbnail_id() result in a local variable to avoid duplicate calls - Remove redundant esc_attr() to prevent double-escaping since the output loop already escapes tag values Fixes sailthru#129
enescala
force-pushed
the
fix/meta-tags-array-offset-warning
branch
from
March 10, 2026 20:42
fb81bd8 to
ffd6f0a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
$post->ID→$post_object->IDingenerate_meta_tags()to match the rest of the methodis_array()checks before accessingwp_get_attachment_image_src()return values, which returnsfalsewhen the attachment is missingTest plan
Fixes #129