Skip to content

fix(model): skip commit callbacks when callbacks = false - #4378

Merged
bpamiri merged 5 commits into
developfrom
peter/callbacks-false-after-commit
Oct 5, 2026
Merged

bpamiri merged 5 commits into
developfrom
peter/callbacks-false-after-commit

Conversation

@bpamiri

@bpamiri bpamiri commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

callbacks = false also skips the commit callbacks

save(callbacks = false) and delete(callbacks = false) skipped every callback except afterCommit and afterRollback, which they still queued. They now skip those too.

$enqueueTransactionCallbacks() takes a callbacks argument. With callbacks = false it queues only the saved-change restore, the same path a model without commit callbacks already takes. A callbacks = false save that rolls back therefore still puts back what savedChanges() reported before it.

A save that changes nothing still queues afterCommit, as before.

Specs

vendor/wheels/tests/specs/model/callbacksFalseAfterCommitSpec.cfc, on the tag model with afterCommit and afterRollback registered:

  • create, update and delete with callbacks = false: no commit callback runs;
  • a rolled-back save with callbacks = false: no afterRollback;
  • a rolled-back callbacks = false save: savedChanges() equals its value from before the save;
  • with callbacks = true: they run, as before.

RED on develop: the four callbacks = false cases fail. The savedChanges() case was checked against a version that skipped the queue entirely, and it fails there.

GREEN, Lucee 7 + SQLite: full suite 6852/6852 after merging develop; complexity gate passes.

🤖 Generated with Claude Code

bpamiri and others added 4 commits October 5, 2026 09:47
save(callbacks = false) and delete(callbacks = false) skipped every other
callback but still queued afterCommit / afterRollback. They now skip those
too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>
…lse-after-commit

Signed-off-by: Peter Amiri <peter@alurium.com>

# Conflicts:
#	vendor/wheels/model/create.cfm
…e rolls back

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>
@bpamiri

bpamiri commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Review @ 7d225d3: source looks good. Final verdict after matrix 37344694616 and PR CI

  • The change. $enqueueTransactionCallbacks() gains callbacks = true, and !arguments.callbacks now takes the same branch as "no transaction callbacks": it queues only $enqueueSavedChangesRestore(). All three call sites pass callbacks = arguments.callbacks: the create and update branches of $save() and delete(). There are no other call sites. With callbacks = true the path is untouched.
  • savedChanges() stays correct after a rolled-back callbacks = false save. The restore entry (feat(model): report what the last save wrote with savedChanges() #4349's callbacks = false queue entry) is still queued inside a real transaction, so $restoreSavedChangesBeforeQueue() puts back the pre-save state on rollback. "still puts back savedChanges() when a callbacks = false save rolls back" asserts t.savedChanges() equals the earlier snapshot. A version that skipped the enqueue entirely would leave the rolled-back save's changes visible and fail it, which is the guard orch1 asked for.
  • No change with callbacks = true. "still runs them with callbacks = true" checks the exact log (commit:…, commit:…, rollback:…), and "still queues afterCommit for a save that changes nothing" pins the no-op case.
  • dependent= deletes ignore callbacks=false; invalid dependent= fails late #4373 (dependent= deletes ignoring callbacks = false) is not folded in. There's no change to the association dependent path, and dependent= deletes ignore callbacks=false; invalid dependent= fails late #4373 is still open, so it's separate.
  • Branch freshness. The branch is behind develop, but develop hasn't touched callbacks.cfm, create.cfm or delete.cfm since its base, and git merge-tree reports a clean merge.

INFO (wording): the fragment's last sentence, "A save that changes nothing still queues afterCommit", could be read as applying with callbacks = false too. What the spec pins is the callbacks = true case. "(with callbacks on)" would remove the ambiguity.

No findings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Wheels Test Results

224 212 tests   219 091 ✅  1h 26m 19s ⏱️
 17 504 suites    5 121 💤
     32 files          0 ❌

Results for commit 7d225d3.

@bpamiri

bpamiri commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

FINAL: APPROVE. Head c1c50b8.

  • Compat matrix 37344694616 ran on 7d225d3: 32/32 legs green, 0 fail, 0 error. callbacksFalseAfterCommitSpec is 7/7 with 0 skipped on every leg.
  • The only commit after the matrix (c1c50b8) changes one line of changelog.d/callbacks-false-commit-callbacks.fixed.md. It now says "With callbacks on, a save that changes nothing still queues afterCommit", which addresses my INFO about the fragment wording. Nothing executable changed, so the matrix covers this head.
  • PR CI on c1c50b8: 18 pass, 0 fail, 0 pending, 2 skipping.

@bpamiri
bpamiri merged commit 0efe228 into develop Oct 5, 2026
20 checks passed
@bpamiri
bpamiri deleted the peter/callbacks-false-after-commit branch October 5, 2026 19:08
bpamiri added a commit that referenced this pull request Oct 5, 2026
…de (#4386)

* docs: note bulk-write transactions and callbacks=false in the app guide

insertAll() / upsertAll() now run a call's batches in one transaction
(#4367), and save()/delete() with callbacks=false skip afterCommit and
afterRollback (#4378).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>

* docs: name invokeWithTransaction(), not a transaction() helper

There is no transaction() function. Say where a bulk call joins an open
transaction, and that its default comes from transactionMode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>

---------

Signed-off-by: Peter Amiri <peter@alurium.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant