Skip to content

Fix PHP 8+ undefined array key warning in merge_extra_image_details#752

Open
rollecode wants to merge 1 commit into
sybrew:masterfrom
rollecode:fix/php8-undefined-array-key-warning
Open

Fix PHP 8+ undefined array key warning in merge_extra_image_details#752
rollecode wants to merge 1 commit into
sybrew:masterfrom
rollecode:fix/php8-undefined-array-key-warning

Conversation

@rollecode
Copy link
Copy Markdown

Problem

Accessing $details['id'] directly on line 692 triggers a PHP 8+ warning when the array key doesn't exist:

PHP Warning: Undefined array key "id" in inc/classes/meta/image.class.php on line 692

Solution

Replace if ( $details['id'] ) with if ( ! empty( $details['id'] ) ) to safely check the key existence before accessing it.

This PR adds the fix.

@sybrew
Copy link
Copy Markdown
Owner

sybrew commented Dec 18, 2025

Hi @ronilaukkarinen, thank you for opening this PR!

$details['id'] is a required index -- we must not suppress this error; the caller must fix it.
I suspect this comes from a third-party implementation.

Do you have an extended log of the error?

@rollecode
Copy link
Copy Markdown
Author

rollecode commented Dec 18, 2025

We had endless warnings like this before my patch:

2025-12-18T09:38:45.506690413Z | xxxxxxxxx [18-Dec-2025 09:38:45 UTC] PHP Warning:  Undefined array key "id" in /var/www/xxxxxxxxx/deploy/releases/xxxxxxxxx/content/plugins/autodescription/inc/classes/meta/image.class.php on line 692
2025-12-18T09:38:36.983584857Z | xxxxxxxxx [18-Dec-2025 09:38:34 UTC] PHP Warning:  Undefined array key "id" in /var/www/xxxxxxxxx/deploy/releases/xxxxxxxxx/content/plugins/autodescription/inc/classes/meta/image.class.php on line 692

I think we don't have any third party stuff interfering.

@sybrew
Copy link
Copy Markdown
Owner

sybrew commented May 13, 2026

Thanks for the follow-up. Sorry for the delay.

All TSF internal generators and bundled compatibility generators yield id, so the source is almost certainly custom code in the theme, a mu-plugin, or another plugin hooking the_seo_framework_image_generation_params and adding a callback to cbs or fallback.

In a GitHub search, I found that "Tampere WordPress Multisite Base Theme" has the ID omitted, but in "Tampere Multisite Theme For Tredu," they applied it correctly.

Are you using that theme?

If not, please search the codebase for the_seo_framework_image_generation_params and check every generator callback it registers. Each yielded image details array must contain both the url and id.

If there is no attachment ID, set id to 0; do not omit the key. TSF always required this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants