-
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
FIX Do not load source in SearchableDropdownTrait when lazy-loading #11273
Closed
emteknetnz
wants to merge
1
commit into
silverstripe:5.2
from
creative-commoners:pulls/5.2/lazy-memory
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might result in unexpected behaviour down the line, but there's not a lot we can do about that.
The one place that looks like this might cause problems is
MultiSelectField::performReadonlyTransformation()
- I think that'll need to be updated to use$this->sourceList
instead of$this->getSource()
.Alternatively a new
getSourceList()
method could be added and used in most places that currently usegetSource()
- that's how TagField seems to have gotten around this problem.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes unfortunately it does seem to break
MultiSelectField::performReadonlyTransformation()
when lazy loadingI don't think changing that to use $this->sourceList will really fix this issue, because ultimately it needs to be converted to use an array anyway because in readonly mode it's using a LookField, which internally uses arrays.
To fix this it feels like we need to convert a whole bunch of things to use generators to handle very large sets of options. Given there's a workaround to use a numeric field (which was the old fallback) feels like this is more effort than it's worth, at least for now. Feels more like an API break piece of work where we also get rid of a bunch of the convoluted class hierarchy that exists for dropdowns
I'll close this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The readonly list only needs to display the items from the list which have actually been selected though, right? i.e. the current value of the field. Surely we can get a readonly formfield that displays the values without loading every single record in the DB into an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly
However looking at my closed PR in hindsight, it's honestly hackish. getSource() should just return the source and not care if it's lazyloaded or not