[FEATURE] Add event when a processed file gets invalidated - #34
Open
achimfritz wants to merge 1 commit into
Open
[FEATURE] Add event when a processed file gets invalidated#34achimfritz wants to merge 1 commit into
achimfritz wants to merge 1 commit into
Conversation
achimfritz
force-pushed
the
task/after-processed-file-invalidated
branch
from
September 1, 2026 11:54
8c826a9 to
1e6ad3b
Compare
o-ba
requested changes
Sep 2, 2026
| ``` | ||
|
|
||
| **Use `getPublicUrl()` on the event, not on `getProcessedFile()`.** The file is | ||
| already deleted by the time this event fires, and `getPublicUrl()` on a deleted |
Member
There was a problem hiding this comment.
I think this is not quite true looking at the implementation in ProcessedFile
public function getPublicUrl(): ?string
{
if (isset($this->processingUrl) && $this->processingUrl !== '') {
return $this->processingUrl; // <- before the deleted check
}
if ($this->deleted) {
return null;
}
…
| // already does internally. | ||
| $publicUrl = $processedFile->getPublicUrl(); | ||
| $processedFile->delete(true); | ||
| $this->eventDispatcher->dispatch(new AfterProcessedFileInvalidatedEvent($processedFile, $publicUrl, $file)); |
Member
There was a problem hiding this comment.
Unguarded dispatch. A throwing listener aborts the loop and the save.
| // null once the file is marked deleted, which delete() itself | ||
| // already does internally. | ||
| $publicUrl = $processedFile->getPublicUrl(); | ||
| $processedFile->delete(true); |
Member
There was a problem hiding this comment.
Maybe we should check the return here?
| return $this->publicUrl; | ||
| } | ||
|
|
||
| public function getOriginalFile(): FileInterface |
Member
There was a problem hiding this comment.
getOriginalFile(): FileInterface is always a concrete File
| // react to the removal, e.g. purge that same variant from a CDN. | ||
| // | ||
| // $publicUrl is captured before delete() runs, not read back from $processedFile | ||
| // here: AbstractFile::getPublicUrl() unconditionally returns null once a file is |
Member
There was a problem hiding this comment.
the “unconditionally null” premise is false for a processing_url variant, see comment in README
| final class AfterProcessedFileInvalidatedEvent | ||
| { | ||
| public function __construct( | ||
| private readonly ProcessedFile $processedFile, |
Member
There was a problem hiding this comment.
Suggest to either dispatch before the delete, or pass a record instead of the deleted object.
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.
No description provided.