Skip to content

MONGOID-5848 Revert MONGOID-5822 (8.0 backport)#6015

Merged
jamis merged 1 commit intomongodb:8.0-stablefrom
jamis:5848-revert-MONGOID-5822-8.0
Jul 23, 2025
Merged

MONGOID-5848 Revert MONGOID-5822 (8.0 backport)#6015
jamis merged 1 commit intomongodb:8.0-stablefrom
jamis:5848-revert-MONGOID-5822-8.0

Conversation

@jamis
Copy link
Contributor

@jamis jamis commented Jul 22, 2025

Backport to 8.0

Summary

MONGOID-5822 attempted to fix a regression where child callbacks that depended on parent state were no longer invoked if the child had not changed. However, the fix itself introduced an unacceptable performance regression.

This PR restores the earlier functionality, which will break apps that depend on callbacks being invoked on unmodified children.

For now, the correct way to implement that behavior is to explicitly iterate over the children in a parent callback, e.g.:

class Parent
  include Mongoid::Document
  has_many :children
  after_save { children.each(&:parent_changed_callback) }
end

class Child
  include Mongoid::Document
  belongs_to :parent
  
  def parent_changed_callback
    # ...
  end
end

@jamis jamis added the bug Fixes a bug, with no new features or broken compatibility label Jul 23, 2025
@jamis jamis merged commit 2ad7794 into mongodb:8.0-stable Jul 23, 2025
30 of 66 checks passed
@jamis jamis deleted the 5848-revert-MONGOID-5822-8.0 branch July 23, 2025 14:16
@jamis jamis added bug Fixes a bug, with no new features or broken compatibility and removed bug Fixes a bug, with no new features or broken compatibility labels Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Fixes a bug, with no new features or broken compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants