Fix incorrect object passed to the view when rendering the history compare action #6662
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.
Subject
Currently, when rendering the entity compare view in the history action, only the current (first) entity object will be passed to the view, even when it is going to render the value of the comparing (secondary) entity object. This means that the
field
block of the show field template will receive the first entity (the base object) along with the secondary value (value to compare) when the secondary value is going to be rendered. This can cause problem if the template does not solely rely on the value but also the object for the correct output. This PR fixes this.I am targeting this branch, because it is backward-compatible. Note that after applying the patch, the block
field_compare
in templatebase_show_field.html.twig
will assume the the existence of theobject_compare
variable. This may cause compatibility problem. But given thatSonataAdminExtension
class is annotated@final
, andI think it is still reasonable to say that the patch won't break BC. Otherwise I'd suggest
base_show_field.html.twig
to be changed to something like this:Changelog