Restore buffers and section frames when a template throws - #96
Conversation
render() unwound exactly one output buffer on failure. That is enough only when the render buffer is the sole one open. beginSection() opens a second buffer and pushes a capture frame, so a template that throws mid-section leaves the render buffer orphaned and a stale frame on the stack. Both leak into whatever renders next: output vanishes into the buffer nobody closes, and a later unmatched endSection() consumes the stale frame instead of throwing, silently capturing the wrong content under the wrong name -- which defeats the guard endSection() grew earlier in this cycle. Record the buffer and capture depths on entry and restore both in the catch, rather than assuming a fixed depth of one. The buffering moves from View::render() to AbstractView::captureTemplate() because $capture is private to AbstractView, so the restoration has to live where the state does. PHPUnit was already reporting these renders as risky -- "test code or tested code did not close its own output buffers".
|
Warning Review limit reached
Next review available in: 2 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
render() unwound exactly one output buffer on failure. That is enough only when the render buffer is the sole one open. beginSection() opens a second buffer and pushes a capture frame, so a template that throws mid-section leaves the render buffer orphaned and a stale frame on the stack.
Both leak into whatever renders next: output vanishes into the buffer nobody closes, and a later unmatched endSection() consumes the stale frame instead of throwing, silently capturing the wrong content under the wrong name -- which defeats the guard endSection() grew earlier in this cycle.
Record the buffer and capture depths on entry and restore both in the catch, rather than assuming a fixed depth of one. The buffering moves from View::render() to AbstractView::captureTemplate() because $capture is private to AbstractView, so the restoration has to live where the state does.
PHPUnit was already reporting these renders as risky -- "test code or tested code did not close its own output buffers".