Fix error of reset editables #996
Open
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.
Bug:
Steps:
(1) Create german page with editables.
(2) Create english page with different editables and content.
(3) Add german page as main content document to the english page and apply (and confirm).
(4) Editables and content of german page are shown on english page.
(5) Save and Publish english page.
Expected Behaviour:
English page shows content of german page (inheritance by main content document relation).
Actual Behaviour:
English page shows the old content before adding german page as main content document
This bug occurs only for pages which not implement the TargetingDocumentInterface.
AI comments to this line of code:
Ambiguous Intent: Passing null to setEditables() is not self-documenting. It's unclear if null means "clear all editables," "reset," or "remove references."
Type Safety: If setEditables() expects an array or iterable, passing null can lead to subtle bugs, especially if the internal implementation doesn't explicitly handle null.
Inconsistent Usage: Elsewhere in the code (e.g., changeMainDocumentAction), editables are cleared with an empty array: $doc->setEditables([]);. Mixing null and [] for the same effect is inconsistent.