Skip CollectionField entry-type setup on INDEX/DETAIL pages#7594
Open
lacatoire wants to merge 1 commit intoEasyCorp:5.xfrom
Open
Skip CollectionField entry-type setup on INDEX/DETAIL pages#7594lacatoire wants to merge 1 commit intoEasyCorp:5.xfrom
lacatoire wants to merge 1 commit intoEasyCorp:5.xfrom
Conversation
CollectionConfigurator::configureEntryType() instantiates the target CRUD controller and calls configureFields(PAGE_EDIT) on it (or PAGE_NEW) so it can build entry_type/prototype options. These options are only consumed when the field is rendered as a form (i.e. on NEW/EDIT pages); on INDEX/DETAIL the field falls back to formatCollection() which only reads the value and a custom option. Running configureFields(PAGE_EDIT) on the target controller while displaying the parent entity's DETAIL page does not just waste work: it also runs the user's configureFields() with no real entity instance available, which makes controllers that legitimately read $context->getEntity()->getInstance() inside configureFields() crash on a NULL entity (EasyCorp#7460). Bail out early when the current action is neither EDIT nor NEW so the form setup only happens on the pages that actually need it.
3d057fe to
4420bc7
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
CollectionConfigurator::configureEntryType()instantiates the target CRUD controller and callsconfigureFields(PAGE_EDIT)on it (orPAGE_NEW) so it can buildentry_type/prototype options. These options are only consumed when the field is rendered as a form: on INDEX/DETAIL the field falls back toformatCollection()which only reads the value and a custom option.Running
configureFields(PAGE_EDIT)on the target controller while displaying the parent's DETAIL page wastes work and, more importantly, runs user code with no real entity instance available, which makes controllers that legitimately read$context->getEntity()->getInstance()insideconfigureFields()crash on a NULL entity.Bail out early when the current page is neither EDIT nor NEW so the form setup only happens on the pages that actually need it.
Closes #7460