Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Open
bwood wants to merge 7 commits intophp-vcr:masterfrom
bwood:parseResponse-undefined-offset-1
Open

Prevent HttpUtil::parseResponse() from emitting PHP Notice Undefined offset 1#302
bwood wants to merge 7 commits intophp-vcr:masterfrom
bwood:parseResponse-undefined-offset-1

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.

1 participant