We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The changes introduced in #23388 break templates that loop over generators:
Exception(code: 0): Cannot traverse an already closed generator at ...
In your view composer, or wherever the data for your view is prepared:
while ($someCondition) { ... yield $results; }
In your view:
@foreach ($results as $chunk) <<< This line throws the exception @foreach ($chunk as $record) ... @endforeach @endforeach
The offending line looks like this in the compiled template:
<?php $__currentLoopData = $results; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $chunk): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
The text was updated successfully, but these errors were encountered:
This can be easily reproduced in a fresh Laravel project:
-- routes/web.php Route::get('results', function () { return view('results'); });
-- app/Results.php class Results { public function generate() { for ($count = 1; $count < 10; $count ++) { yield ['a', 'b', 'c']; } } }
-- resources/views/results.blade.php @inject('results', 'App\Results') @foreach($results->generate() as $chunks) <div> @foreach($chunks as $chunk) {{ $chunk }} @endforeach </div> @endforeach
Using Laravel 5.5.36 you get the expected result:
a b c a b c a b c a b c a b c a b c a b c a b c a b c
Using any version after merging #23388 results in:
Cannot traverse an already closed generator (View: my-project/resources/views/results.blade.php)
It should be reverted until it provides a solution that doesn't break basic PHP functionality.
Sorry, something went wrong.
No branches or pull requests
Description:
The changes introduced in #23388 break templates that loop over generators:
Steps To Reproduce:
In your view composer, or wherever the data for your view is prepared:
In your view:
The offending line looks like this in the compiled template:
The text was updated successfully, but these errors were encountered: