mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
438a51956a
commit
00eb220e91
@ -454,9 +454,8 @@ class ViewableData extends Object implements IteratorAggregate {
|
||||
* template.
|
||||
*/
|
||||
public function XML_val($field, $arguments = null, $cache = false) {
|
||||
if($result = $this->obj($field, $arguments, false, $cache)) {
|
||||
return is_object($result) ? $result->forTemplate() : $result;
|
||||
}
|
||||
$result = $this->obj($field, $arguments, false, $cache);
|
||||
return is_object($result) ? $result->forTemplate() : $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user