-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SearchableDropdownTrait::getSource doesn't respect lazy-loading #11272
Comments
There are two different code paths that lead to calling One is in the The other is only when rendering the field in a react form (e.g. in elemental blocks). The call to |
Ultimately the fact that Regardless, the return type is strongly typed so we can't just change that in CMS 5. I'll submit a PR that fixes it for 5, and then submit another PR that fixes it better for 6. |
Linked PR has been merged, it will be automatically tagged shortly |
Reopened and assigned to me as per instructions in issue description |
|
Module version(s) affected
5.2.10
Description
Prior to Silverstripe 5.2 auto scaffolding of has_one relations would use a NumericField when there were over 100 items.
With the introduction of SearchableDropdownField the auto scaffolding now uses lazy-loading for large lists.
Unfortunately in the construction of the SearchableDropdownField
getSource
is called bygetSourceEmpty
. Even for lazy loaded SearchableDropdownFields.SearchableDropdownTrait::getSource
in turn callsSelectField::getListMap
which tries to convert the large list into an array in memory.As far as I can tell this array is never used, since the lazy-loading search will work on the Search Context to find elements.
But trying to create the array on large lists leads to the form failing to render with a timeout or memory exhaustion.
How to reproduce
Reproduction Steps:
ClassA
has_oneClassB
,ClassB
has_manyClassA
)Possible Solution
Don't call getSource on lazyloaded SearchableDropdownFields.
Additional Context
Workaround: In ClassA::getCMSFields replace SearchableDropdownField with NumericField.
Validations
silverstripe/installer
(with any code examples you've provided)New issues created
PRs
AFTER merging PR
Reassign to Guy - I want to revert these changes and do the cleaner (API breaking) fix in CMS 6.
The text was updated successfully, but these errors were encountered: