Permalink
Browse files

BUGFIX Stricter object type checks in ViewableData->hasValue() and Vi…

…ewableData->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
  • Loading branch information...
1 parent daa0a42 commit a3cf47f5ec1e706fdbfc07b22624b3071fc5f515 @chillu chillu committed Oct 15, 2010
Showing with 3 additions and 2 deletions.
  1. +3 −2 core/ViewableData.php
View
5 core/ViewableData.php
@@ -423,9 +423,10 @@ public function cachedCall($field, $arguments = null, $identifier = null) {
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 @@ public function hasValue($field, $arguments = null, $cache = true) {
*/
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;
}
/**

0 comments on commit a3cf47f

Please sign in to comment.