BUGFIX Stricter object type checks in ViewableData->hasValue() and ViewableData->XMLval(). Broke in cases when SS_HTTPResponse is returned which doesn't extend from Object, hence doesn't have an exist() method (fixes #5524, thanks hamish) (from r105278)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112477 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-10-15 02:30:57 +00:00
parent daa0a42aa1
commit a3cf47f5ec

View File

@ -423,9 +423,10 @@ class ViewableData extends Object implements IteratorAggregate {
public function hasValue($field, $arguments = null, $cache = true) {
$result = $cache ? $this->cachedCall($field, $arguments) : $this->obj($field, $arguments, false, false);
if(is_object($result)) {
if(is_object($result) && $result instanceof Object) {
return $result->exists();
} else {
// Empty paragraph checks are a workaround for TinyMCE
return ($result && $result !== '<p></p>');
}
}
@ -443,7 +444,7 @@ class ViewableData extends Object implements IteratorAggregate {
*/
public function XML_val($field, $arguments = null, $cache = false) {
$result = $this->obj($field, $arguments, false, $cache);
return is_object($result) ? $result->forTemplate() : $result;
return (is_object($result) && $result instanceof Object) ? $result->forTemplate() : $result;
}
/**