Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent HttpUtil::parseResponse() from emitting PHP Notice Undefined offset 1 #302

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

bwood
Copy link
Contributor

@bwood bwood commented May 1, 2020

Context

As mentioned in #272, it's possible for HttpUtil::parseResponse() to receive a empty $response argument. In this case php-VCR emits

PHP Notice:  Undefined offset: 1 in /opt/WpsConsole/vendor/php-vcr/php-vcr/src/VCR/Util/HttpUtil.php on line 70

which causes a Behat test to fail.

What has been done

Use array_pad() to ensure that the array created from an empty response argument has at least two empty elements.

Add HttpUtilTest::parseResponseNull() to assert correct behavior if the response is null.

How to test

In my case I needed to create a new fixture for a [getUser()|https://docs.aws.amazon.com/IAM/latest/APIReference/API_GetUser.html] call to AWS IAM. Doing that exposed this bug.

Notes

I used the same approach as #242

@bwood bwood changed the base branch from master to 1.5 February 21, 2024 15:16
@bwood bwood changed the base branch from 1.5 to master February 21, 2024 15:18
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.

None yet

1 participant