mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #8146 from open-sausages/pulls/3/fix-weird-crash
BUG Fix crash on ID in default_sort
This commit is contained in:
commit
1d0cffd0e4
@ -1959,7 +1959,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
$items = isset($items) ? array_merge((array) $items, $dbItems) : $dbItems;
|
||||
}
|
||||
}
|
||||
|
||||
// If we requested a non-existant named field return null instead of all fields
|
||||
if ($fieldName) {
|
||||
return null;
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
@ -3433,16 +3436,18 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
if ($table && strtolower($table) !== strtolower($this->class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list($fieldType) = SS_Object::parse_class_spec($this->db($column));
|
||||
$isAutoIndexable = (Config::inst()->get($fieldType, 'auto_indexable')
|
||||
|| Config::inst()->get("DB{$fieldType}", 'auto_indexable'));
|
||||
|
||||
if (
|
||||
$this->hasOwnTableDatabaseField($column)
|
||||
&& !array_key_exists($column, $indexes)
|
||||
&& $isAutoIndexable
|
||||
) {
|
||||
// Skip already indexed columns
|
||||
if (array_key_exists($column, $indexes)) {
|
||||
continue;
|
||||
}
|
||||
// Get field type (including fixed fields) on this table, if it exists
|
||||
$fieldType = $this->hasOwnTableDatabaseField($column);
|
||||
if (!$fieldType) {
|
||||
continue;
|
||||
}
|
||||
$isAutoIndexable = Config::inst()->get($fieldType, 'auto_indexable')
|
||||
|| Config::inst()->get("DB{$fieldType}", 'auto_indexable');
|
||||
if ($isAutoIndexable) {
|
||||
$indexes[$column] = true;
|
||||
}
|
||||
} catch (InvalidArgumentException $e) { }
|
||||
|
@ -1857,6 +1857,8 @@ class DataObjectTest_Fixture extends DataObject implements TestOnly {
|
||||
'DateField.Nice' => 'Date'
|
||||
);
|
||||
|
||||
private static $default_sort = '"DataObjectTest_Fixture"."ID" ASC';
|
||||
|
||||
private static $searchable_fields = array();
|
||||
|
||||
public function populateDefaults() {
|
||||
|
Loading…
Reference in New Issue
Block a user