Fix: AfterChunk event raised after sheet disconnect - #4385
Open
zigzagdev wants to merge 2 commits into
Open
Conversation
Member
|
can you retarget this to 4.x |
zigzagdev
force-pushed
the
fix/after-chunk-method-timing
branch
from
July 14, 2026 11:24
a7d43d8 to
f3f520c
Compare
zigzagdev
force-pushed
the
fix/after-chunk-method-timing
branch
from
July 14, 2026 12:51
1224015 to
dc5012e
Compare
Author
I changed target branch. So please check my PR. |
4 tasks
AJenbo
reviewed
Jul 27, 2026
Comment on lines
+163
to
167
| $sheet->raise(new AfterChunk($sheet, $this->import, $this->startRow)); | ||
|
|
||
| $sheet->disconnect(); | ||
|
|
||
| $this->cleanUpTempFile(); |
There was a problem hiding this comment.
NIT: raise can throw so just in case it does it could be best to make sure the disconnect and cleanup still happens.
Suggested change
| $sheet->raise(new AfterChunk($sheet, $this->import, $this->startRow)); | |
| $sheet->disconnect(); | |
| $this->cleanUpTempFile(); | |
| try { | |
| $sheet->raise(new AfterChunk($sheet, $this->import, $this->startRow)); | |
| } finally { | |
| $sheet->disconnect(); | |
| $this->cleanUpTempFile(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1️⃣Why should it be added? What are the benefits of this change?
AfterChunkwas fired afterSheet::disconnect()inReadChunk::handle().disconnect()callsunset($this->worksheet), so any event handler that accesses$event->getSheet()->getDelegate()would encounter an undefined property and receivenullinstead of the expectedWorksheetinstance.Moving
raise(AfterChunk)beforedisconnect()ensures the worksheet is still accessible inside event handlers, which is the naturally expected behavior.2️⃣Does it contain multiple, unrelated changes?
No.
This PR contains a single focused fix: reordering
raise(AfterChunk)anddisconnect()inReadChunk::handle().3️⃣Does it include tests, if possible?
Yes.
test_after_chunk_event_sheet_delegate_is_accessiblehas been added toWithEventsTest, asserting that$event->getSheet()->getDelegate()returns aWorksheetinstance within anAfterChunkhandler.4️⃣Any drawbacks? Possible breaking changes?
No breaking changes.
The fix only corrects the order of two operations. Event handlers that do not access
getDelegate()are unaffected.5️⃣Tasks
Test Results