mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #1090 from sminnee/fix-get-one-case
FIX: Fix DataObject::get_one() when the classname is passed with imprope...
This commit is contained in:
commit
4f39af1a85
@ -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]->destroyed) {
|
||||
|
||||
DataObject::$_cache_get_one[$callerClass][$cacheKey
|
||||
] = false;
|
||||
DataObject::$_cache_get_one[$callerClass][$cacheKey] = false;
|
||||
}
|
||||
if(!$cache || !isset(DataObject::$_cache_get_one[$callerClass][$cacheKey])) {
|
||||
$dl = DataList::create($callerClass)->where($filter)->sort($orderby);
|
||||
$dl->setDataModel(DataModel::inst());
|
||||
$dl = $callerClass::get()->where($filter)->sort($orderby);
|
||||
$item = $dl->First();
|
||||
|
||||
if($cache) {
|
||||
|
@ -171,6 +171,10 @@ class DataObjectTest extends SapphireTest {
|
||||
$this->assertEquals('Bob', $comment->Name);
|
||||
$comment = DataObject::get_one('DataObjectTest_TeamComment', '', true, '"Name" DESC');
|
||||
$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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user