Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

FIX: Fix DataObject::get_one() when the classname is passed with impr…

…oper casing.
  • Loading branch information...
commit f4efaeefa73ce2163399b3b4a6622cbe026a0a25 1 parent e8bfc24
@sminnee sminnee authored
Showing with 6 additions and 4 deletions.
  1. +2 −4 model/DataObject.php
  2. +4 −0 tests/model/DataObjectTest.php
View
6 model/DataObject.php
@@ -2850,12 +2850,10 @@ public static function get_one($callerClass, $filter = "", $cache = true, $order
&& 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) {
View
4 tests/model/DataObjectTest.php
@@ -171,6 +171,10 @@ public function testGet() {
$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() {
Please sign in to comment.
Something went wrong with that request. Please try again.