3212 Posts in 847 Topics by 809 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 760 Views |
-
bugfix: boolean logic support in templates

29 April 2011 at 3:45am Last edited: 29 April 2011 3:47am
Hi team,
The SSViewer falls over when encountering some AND/OR boolean logic in the template. The PHP generated will break the parser.
This can be fixed in SSViewer::parseTemplateContent():
sapphire/core/SSViewer.phpby changing line 543:
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *\\|\\|? *([A-Za-z0-9_]+) +%' . '>', '<? else_if($item->hasValue("\\1") || $item->hasValue("\\2")) { ?>', $content);to:
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *\\|\\|? *([A-Za-z0-9_]+) +%' . '>', '<? } else if($item->hasValue("\\1") || $item->hasValue("\\2")) { ?>', $content);and changing line 547:
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *&&? *([A-Za-z0-9_]+) +%' . '>', '<? else_if($item->hasValue("\\1") && $item->hasValue("\\2")) { ?>', $content);to:
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *&&? *([A-Za-z0-9_]+) +%' . '>', '<? } else if($item->hasValue("\\1") && $item->hasValue("\\2")) { ?>', $content);Cheers, Matt
-
Re: bugfix: boolean logic support in templates

30 April 2011 at 1:40am Last edited: 30 April 2011 1:42am
Hi Matt,
Could you provide a series of unit test scripts for this or show that it's covered by existing tests. Does your change break any existing tests?
The status of 2.4.x is that it's only really critical or security issues getting through. There may be an intermediate 2.5 release before 3.0 which could include fixes such as this but we would not want to introduce any bugs of course (hence the tests!). SSViewer has been completely overhauled in master so hopefully should already be fine in that!
FYI any changes, bugfixes or other patches should be submitted via github. See http://doc.silverstripe.org/sapphire/en/misc/contributing#sending-pull-requests-for-git for more information.
-
Re: bugfix: boolean logic support in templates

26 July 2011 at 10:13pm
Yep!
It was only a matter of remove the undescore from "else_if" to transform it in the correct PHP's "else if"Thanks
| 760 Views | ||
|
Page:
1
|
Go to Top |


