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

Skip to content

BUGFIX: ErrorException in VCR/Storage/Yaml.php:61#295

Open
bomas13 wants to merge 2 commits intophp-vcr:masterfrom
bomas13:bomas13-patch
Open

BUGFIX: ErrorException in VCR/Storage/Yaml.php:61#295
bomas13 wants to merge 2 commits intophp-vcr:masterfrom
bomas13:bomas13-patch

Conversation

@bomas13
Copy link

@bomas13 bomas13 commented Jan 31, 2020

Context

if the fixture is recently created and it has no content, the parser returns null to $recording. And array-like access to null via $recording[0] will raise an exception. With this little check this behavior is fixed and also all tests will work properly.

What has been done

  • added a check if $response is null

How to test

  • write a simple vcr test and try to record a whole new fixture

Todo

  • merge into php-vcr/php-vcr:master and tag a new version

Notes

morozov and others added 2 commits January 6, 2020 13:28
Do not return the stat since we don't know the resulting the size that the file will have after having all transformations applied. When including files, PHP 7.4 and newer are sensitive to file size reported by stat.
if the fixture is recently created and it has no content, the parser returns null to $recording. And array-like access to null via $recording[0] will raise an exception. With this little check this behavior is fixed and also all tests will work properly.
@bwood
Copy link
Contributor

bwood commented Apr 27, 2020

Since commit 42ec927 already has a separate PR (#293) which pre-dates this one, maybe it would be better to treat these two issues separately?

$recording = $this->yamlParser->parse($this->readNextRecord());
$this->current = $recording[0];
++$this->position;
if (!is_null($recording)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It shouldn't happen, but if $recording = 'some string', unintended things will happen. I'd suggest:

if (is_array($recording) && count($recording))

Tjeerd pushed a commit to ibuildingsnl/php-vcr that referenced this pull request Oct 30, 2020
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.

3 participants