BUGFIX Don't return empty value from ViewableData->XML_val() if the actual value is an uncasted 0 integeter (or anything else evaluating to untyped boolean false)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@89161 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-10-15 21:48:24 +00:00
parent 438a51956a
commit 00eb220e91
2 changed files with 9 additions and 3 deletions

View File

@ -454,10 +454,9 @@ class ViewableData extends Object implements IteratorAggregate {
* template.
*/
public function XML_val($field, $arguments = null, $cache = false) {
if($result = $this->obj($field, $arguments, false, $cache)) {
$result = $this->obj($field, $arguments, false, $cache);
return is_object($result) ? $result->forTemplate() : $result;
}
}
/**
* Return the value of the field without any escaping being applied.

View File

@ -26,6 +26,11 @@ class ViewableDataTest extends SapphireTest {
$this->assertEquals('<foo>', $caster->XML_val('castedUnsafeXML'));
}
public function testUncastedXMLVal() {
$caster = new ViewableDataTest_Castable();
$this->assertEquals($caster->XML_val('uncastedZeroValue'), 0);
}
public function testArrayCustomise() {
$viewableData = new ViewableDataTest_Castable();
$newViewableData = $viewableData->customise(array (
@ -67,6 +72,8 @@ class ViewableDataTest_Castable extends ViewableData {
public $test = 'test';
public $uncastedZeroValue = 0;
public function alwaysCasted() {
return 'alwaysCasted';
}