mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Don't scaffold has_one relations into a DropdownField in ForeignKey->scaffoldFormField() if more than 100 records would be created, to avoid exceeding PHP memory (fixes #6776)
This commit is contained in:
parent
dd517c49ba
commit
4b8895c8b6
@ -37,8 +37,15 @@ class ForeignKey extends Int {
|
||||
$field = new UploadField($relationName, $title);
|
||||
} else {
|
||||
$titleField = (singleton($hasOneClass)->hasField('Title')) ? "Title" : "Name";
|
||||
$map = DataList::create($hasOneClass)->map("ID", $titleField);
|
||||
$field = new DropdownField($this->name, $title, $map, null, null, ' ');
|
||||
$list = DataList::create($hasOneClass);
|
||||
// Don't scaffold a dropdown for large tables, as making the list concrete
|
||||
// might exceed the available PHP memory in creating too many DataObject instances
|
||||
if($list->count() < 100) {
|
||||
$field = new DropdownField($this->name, $title, $list->map("ID", $titleField), null, null, ' ');
|
||||
} else {
|
||||
$field = new NumericField($this->name, $title);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $field;
|
||||
|
Loading…
Reference in New Issue
Block a user