mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00: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);
|
$field = new UploadField($relationName, $title);
|
||||||
} else {
|
} else {
|
||||||
$titleField = (singleton($hasOneClass)->hasField('Title')) ? "Title" : "Name";
|
$titleField = (singleton($hasOneClass)->hasField('Title')) ? "Title" : "Name";
|
||||||
$map = DataList::create($hasOneClass)->map("ID", $titleField);
|
$list = DataList::create($hasOneClass);
|
||||||
$field = new DropdownField($this->name, $title, $map, null, null, ' ');
|
// 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;
|
return $field;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user