Skip to content

Fix undefined array key warnings breaking JSON response in getAllHeaders#24

Merged
nicklansley merged 1 commit into
gs1:masterfrom
rmedic:fix/php-undefined-array-keys
May 19, 2026
Merged

Fix undefined array key warnings breaking JSON response in getAllHeaders#24
nicklansley merged 1 commit into
gs1:masterfrom
rmedic:fix/php-undefined-array-keys

Conversation

@rmedic
Copy link
Copy Markdown

@rmedic rmedic commented Apr 14, 2026

$params['mediaType'] and $params['lang'] are optional query parameters that may not be present in every request. In PHP 8, accessing a missing array key emits a Warning that, with display_errors enabled, gets prepended to the JSON response body and makes it unparseable by the JavaScript test runner.

Fixed by using null-coalescing operators so absent params default to null rather than triggering a warning.

$params['mediaType'] and $params['lang'] are optional query parameters
that may not be present in every request. In PHP 8, accessing a missing
array key emits a Warning that, with display_errors enabled, gets
prepended to the JSON response body and makes it unparseable by the
JavaScript test runner.

Fixed by using null-coalescing operators so absent params default to
null rather than triggering a warning.
@sboeckelmann
Copy link
Copy Markdown
Contributor

@philarcher +1 #24 #25 and #26 all looking nice and would "unblock" some of our testcases as well

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes PHP 8 “undefined array key” warnings in the getAllHeaders test handler that can corrupt JSON API responses (when display_errors is enabled) by ensuring optional query parameters default to null when absent.

Changes:

  • Use null-coalescing for optional $params['mediaType'] and $params['lang'] when calling getCustomHeaders(...).
  • Prevent warnings from being emitted into the JSON response body for requests that omit these parameters.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nicklansley nicklansley merged commit 9333641 into gs1:master May 19, 2026
4 checks passed
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.

4 participants