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

1.5.5 parse response undefined offset 1 #403

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

Conversation

bwood
Copy link
Contributor

@bwood bwood commented Feb 23, 2024

Context

This is a re-roll of #302 to achieve a patch that is compatible with php-vcr 1.5.5.

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

zebraf1 and others added 30 commits April 8, 2022 10:03
Fix issue where dispatch() was called with wrong order of parameters when using Codeception 4.1.15 or higher which added a class alias for EventDispatcher\Event.
Using recommendation by @Naktibalda to detect which version of dispatch method must be used
This reverts commit 71a2ede, reversing
changes made to 989fdca.

We should not drop support for php 7.2 as this minor release is the only
release supporting lower php version and we won't be able to release bugfixes
if we drop this.
(cherry picked from commit 783a29a)
(cherry picked from commit e22c1d6)

# Conflicts:
#	.github/workflows/tests.yml
#	composer.json
#	phpstan.neon
#	tests/Integration/Guzzle/AsyncTest.php
#	tests/Integration/Guzzle/ErrorTest.php
#	tests/Integration/Soap/ExampleSoapClient.php
#	tests/Integration/Soap/ExampleSoapClientTest.php
#	tests/Unit/CassetteTest.php
#	tests/Unit/CodeTransform/AbstractCodeTransformTest.php
#	tests/Unit/CodeTransform/CurlCodeTransformTest.php
#	tests/Unit/CodeTransform/SoapCodeTransformTest.php
#	tests/Unit/ConfigurationTest.php
#	tests/Unit/Event/AfterHttpRequestEventTest.php
#	tests/Unit/Event/AfterPlaybackEventTest.php
#	tests/Unit/Event/BeforeHttpRequestEventTest.php
#	tests/Unit/Event/BeforePlaybackEventTest.php
#	tests/Unit/Event/BeforeRecordEventTest.php
#	tests/Unit/LibraryHooks/CurlHookTest.php
#	tests/Unit/LibraryHooks/SoapHookTest.php
#	tests/Unit/LibraryHooks/StreamWrapperHookTest.php
#	tests/Unit/RequestMatcherTest.php
#	tests/Unit/RequestTest.php
#	tests/Unit/ResponseTest.php
#	tests/Unit/Storage/AbstractStorageTest.php
#	tests/Unit/Storage/BlackholeTest.php
#	tests/Unit/Storage/JsonTest.php
#	tests/Unit/Storage/YamlTest.php
#	tests/Unit/Util/CurlHelperTest.php
#	tests/Unit/Util/HttpClientTest.php
#	tests/Unit/Util/HttpUtilTest.php
#	tests/Unit/Util/SoapClientTest.php
#	tests/Unit/Util/StreamHelperTest.php
#	tests/Unit/Util/StreamProcessorTest.php
#	tests/Unit/Util/TextUtilTest.php
#	tests/Unit/VCRFactoryTest.php
#	tests/Unit/VCRTest.php
#	tests/Unit/VideorecorderTest.php
#	tests/bootstrap.php
#	tests/integration/guzzle/5/ExampleHttpClient.php
#	tests/integration/guzzle/6/ExampleHttpClient.php
#	tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php
#	tests/integration/guzzle/test/bootstrap.php
#	tests/integration/soap/test/bootstrap.php
# Conflicts:
#	.github/workflows/continuous integration.yml
…le Cassette to playback and record request/responses at a given index. Do not require Cassette to manage index state.

(cherry picked from commit 7590bbc)
bwood and others added 22 commits December 19, 2022 19:16
… the recording index.

(cherry picked from commit 9037b98)
…y exists in the cassette.

(cherry picked from commit d5adfb4)
(cherry picked from commit edb27bd)
… no index keys playback.

(cherry picked from commit 074fb85)
…ed cassettes playback multiple identical requests correctly.

(cherry picked from commit 1011e40)
…is called as part of eject() and insertCassette().

(cherry picked from commit 5cdd0a0)
(cherry picked from commit ad35687)
(with and without legacy entries)

(cherry picked from commit ce1471b)
(cherry picked from commit a95298b)
(cherry picked from commit 457326c)
…te have to handle legacy entries

Because the Videorecorder increments the index for each identical requests it also passes it to the cassette,
so the cassette have to handle legacy stored entries. So if no index is present while loading recorded requests
we have to set the index to searched one (instead of zero) to always match (disabled the feature), when all
other matchers match.

(cherry picked from commit 9672154)
This reverts commit ce1471b.

(cherry picked from commit 2ebf001)
(cherry picked from commit 63de5ce)
php-vcr#336 Proper Detection of EventDispatcherInterface [1.5]
First read the whole stream and afterwards perform code transformations.
This will ensure to also replace code, which is divided into chunks while
reading a file.

Fixes php-vcr#268 and php-vcr#383

(cherry picked from commit 1917d66)
…nsformation-on-streams-which-are-divided-into-several-chunks

FIX: Read the whole stream and perform code transformations
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

4 participants