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;
|
$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;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3433,16 +3436,18 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
if ($table && strtolower($table) !== strtolower($this->class)) {
|
if ($table && strtolower($table) !== strtolower($this->class)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// Skip already indexed columns
|
||||||
list($fieldType) = SS_Object::parse_class_spec($this->db($column));
|
if (array_key_exists($column, $indexes)) {
|
||||||
$isAutoIndexable = (Config::inst()->get($fieldType, 'auto_indexable')
|
continue;
|
||||||
|| Config::inst()->get("DB{$fieldType}", 'auto_indexable'));
|
}
|
||||||
|
// Get field type (including fixed fields) on this table, if it exists
|
||||||
if (
|
$fieldType = $this->hasOwnTableDatabaseField($column);
|
||||||
$this->hasOwnTableDatabaseField($column)
|
if (!$fieldType) {
|
||||||
&& !array_key_exists($column, $indexes)
|
continue;
|
||||||
&& $isAutoIndexable
|
}
|
||||||
) {
|
$isAutoIndexable = Config::inst()->get($fieldType, 'auto_indexable')
|
||||||
|
|| Config::inst()->get("DB{$fieldType}", 'auto_indexable');
|
||||||
|
if ($isAutoIndexable) {
|
||||||
$indexes[$column] = true;
|
$indexes[$column] = true;
|
||||||
}
|
}
|
||||||
} catch (InvalidArgumentException $e) { }
|
} catch (InvalidArgumentException $e) { }
|
||||||
|
@ -1857,6 +1857,8 @@ class DataObjectTest_Fixture extends DataObject implements TestOnly {
|
|||||||
'DateField.Nice' => 'Date'
|
'DateField.Nice' => 'Date'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $default_sort = '"DataObjectTest_Fixture"."ID" ASC';
|
||||||
|
|
||||||
private static $searchable_fields = array();
|
private static $searchable_fields = array();
|
||||||
|
|
||||||
public function populateDefaults() {
|
public function populateDefaults() {
|
||||||
|
Loading…
Reference in New Issue
Block a user