Skip to content

Commit 9338be8

Browse files
devinleclaude
andcommitted
fix: add null coalescing check for context param in Gutenberg.php
Add null coalescing operator to check for context parameter existence before accessing it in extend_post_content method. This prevents PHP 8+ "Undefined array key" warnings that corrupt JSON responses when the context query parameter is not explicitly provided in REST API requests. Fixes #940 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 335f73b commit 9338be8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@headstartwp/headstartwp": patch
3+
---
4+
5+
Fix: Add null coalescing check for context parameter in extend_post_content to prevent PHP 8+ "Undefined array key" warning. Fixes #940

wp/headless-wp/includes/classes/Integrations/Gutenberg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function extend_post_content( \WP_REST_Response $data, \WP_Post $post, \W
8787

8888
$params = $request->get_params();
8989

90-
if ( 'view' !== $params['context'] ) {
90+
if ( 'view' !== ( $params['context'] ?? '' ) ) {
9191
return $data;
9292
}
9393

0 commit comments

Comments
 (0)