Skip to content

fix(channel-registry): guard title key with array_key_exists() like other optional args - #652

Open
hmbashar wants to merge 1 commit into
WordPress:developfrom
hmbashar:fix/channel-registry-title-undefined-key
Open

hmbashar wants to merge 1 commit into
WordPress:developfrom
hmbashar:fix/channel-registry-title-undefined-key

Conversation

@hmbashar

@hmbashar hmbashar commented Oct 25, 2026 •

Copy link
Copy Markdown

Fixes #650.

What problem does this fix?

Channel_Registry::register() accessed $parsed['title'] directly without checking if the key exists, unlike every other optional key (context, description, icon) which all use an array_key_exists() guard.

On PHP 8.x this produces:

PHP Warning: Undefined array key "title"

Changes

  • includes/class-channel-registry.php: apply the same array_key_exists() guard to title, defaulting to '' when absent — consistent with how all other optional args are handled.
  • tests/phpunit/tests/test-channel-registry.php: add test_register_channel_without_title() covering registration without a title key.

Testing

phpunit tests/phpunit/tests/test-channel-registry.php
Use of AI Tools

AI assistance: Yes
Tool(s): Claude
Model(s): claude-sonnet-4-6
Used for: Code implementation and test; reviewed and verified by contributor.

…ther optional args

Fixes WordPress#650. Unlike context, description and icon, the title key was
accessed directly via $parsed['title'] without an array_key_exists()
check, producing a PHP 8.x undefined-array-key warning when callers
omit the key. Apply the same guard used for the other optional args,
defaulting to an empty string.

Add test_register_channel_without_title() to cover the missing-title path.

This branch has not been deployed

No deployments
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.

Bug: Channel_Registry::register() accesses $parsed['title'] without array_key_exists() guard

1 participant