-
Notifications
You must be signed in to change notification settings - Fork 67
Improve: allow PreSaveEvent listeners to skip default object persistence #607
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
Merged
kingjia90
merged 5 commits into
pimcore:2026.x
from
ellenico77:feature/presave-event-skip-save
Sep 17, 2026
+65
−1
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
166a8eb
Improve: allow PreSaveEvent listeners to skip default object persistence
ellenico77 b5aed0d
Merge branch 'pimcore:2026.x' into feature/presave-event-skip-save
ellenico77 328b9e9
Merge remote-tracking branch 'origin/2026.x' into pr607
kingjia90 401c084
Document skip-save, log skipped elements and type the flag
kingjia90 f1666de
Reload a skipped element so its unsaved changes cannot leak into a la…
kingjia90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — confirmed and fixed in f1666de.
loadOrCreateAndPrepareElement()resolves throughDataObject::getById()/getByPath(), which return the runtime-cached instance, and both the sequential command and the Messenger handler process many queue items in one process. Before the skip flag this was harmless because every resolved element was saved, so the in-memory state matched the database. With a skip it no longer does, and a later row resolving the same element would have persisted the skipped row's values.The skip path now calls
discardUnsavedChanges(), which reloads an existing element throughElement\Service::getElementById($type, $id, ['force' => true]). The forced load re-registers a clean instance in the runtime cache, so the next row resolving the same element gets database state. Newly created elements have no ID and were never cached, so they are simply dropped.The extra load is paid only on skipped rows that resolved an existing element, and it usually hits the Pimcore item cache rather than the database. Documented in the upgrade note and in
doc/06_Extending/02_Events.md.