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

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

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

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?

@@ -58,8 +58,10 @@ public function storeRecording(array $recording)
public function next()
{
$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.

None yet

3 participants