mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: Fix DataObject::get_one() when the classname is passed with improper casing.
This commit is contained in:
parent
e8bfc241fd
commit
f4efaeefa7
@ -2850,12 +2850,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
&& DataObject::$_cache_get_one[$callerClass][$cacheKey] instanceof DataObject
|
&& DataObject::$_cache_get_one[$callerClass][$cacheKey] instanceof DataObject
|
||||||
&& DataObject::$_cache_get_one[$callerClass][$cacheKey]->destroyed) {
|
&& DataObject::$_cache_get_one[$callerClass][$cacheKey]->destroyed) {
|
||||||
|
|
||||||
DataObject::$_cache_get_one[$callerClass][$cacheKey
|
DataObject::$_cache_get_one[$callerClass][$cacheKey] = false;
|
||||||
] = false;
|
|
||||||
}
|
}
|
||||||
if(!$cache || !isset(DataObject::$_cache_get_one[$callerClass][$cacheKey])) {
|
if(!$cache || !isset(DataObject::$_cache_get_one[$callerClass][$cacheKey])) {
|
||||||
$dl = DataList::create($callerClass)->where($filter)->sort($orderby);
|
$dl = $callerClass::get()->where($filter)->sort($orderby);
|
||||||
$dl->setDataModel(DataModel::inst());
|
|
||||||
$item = $dl->First();
|
$item = $dl->First();
|
||||||
|
|
||||||
if($cache) {
|
if($cache) {
|
||||||
|
@ -171,6 +171,10 @@ class DataObjectTest extends SapphireTest {
|
|||||||
$this->assertEquals('Bob', $comment->Name);
|
$this->assertEquals('Bob', $comment->Name);
|
||||||
$comment = DataObject::get_one('DataObjectTest_TeamComment', '', true, '"Name" DESC');
|
$comment = DataObject::get_one('DataObjectTest_TeamComment', '', true, '"Name" DESC');
|
||||||
$this->assertEquals('Phil', $comment->Name);
|
$this->assertEquals('Phil', $comment->Name);
|
||||||
|
|
||||||
|
// Test get_one() with bad case on the classname
|
||||||
|
$subteam1 = DataObject::get_one('dataobjecttest_subteam', "\"Title\" = 'Subteam 1'", true);
|
||||||
|
$this->assertEquals($subteam1->Title, "Subteam 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSubclassFields() {
|
public function testGetSubclassFields() {
|
||||||
|
Loading…
Reference in New Issue
Block a user