Skip to content

Commit

Permalink
BUG Temp disable shortcode SPLIT behaviour due to crash (#6436)
Browse files Browse the repository at this point in the history
Fixes #5987
  • Loading branch information
Damian Mooyman committed Dec 21, 2016
1 parent c794c29 commit f314b86
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion parsers/ShortcodeParser.php
Expand Up @@ -584,7 +584,8 @@ public function parse($content) {

$location = self::INLINE;
if($class == 'left' || $class == 'right') $location = self::BEFORE;
if($class == 'center' || $class == 'leftAlone') $location = self::SPLIT;
// Note: center / leftAlone should be `self::SPLIT`, but this crashes so we fall back to self::INLINE
// if($class == 'center' || $class == 'leftAlone') $location = self::SPLIT;

if(!$parent) {
if($location !== self::INLINE) {
Expand Down
12 changes: 11 additions & 1 deletion tests/parsers/ShortcodeParserTest.php
Expand Up @@ -185,7 +185,8 @@ protected function assertEqualsIgnoringWhitespace($a, $b, $message = null) {
$this->assertEquals(preg_replace('/\s+/', '', $a), preg_replace('/\s+/', '', $b), $message);
}

public function testtExtract() {
public function testtExtractBefore()
{
// Left extracts to before the current block
$this->assertEqualsIgnoringWhitespace(
'Code<div>FooBar</div>',
Expand All @@ -197,6 +198,13 @@ public function testtExtract() {
'Code<div>Foo<b>BarBaz</b>Qux</div>',
$this->parser->parse('<div>Foo<b>Bar[test_shortcode class=left]Code[/test_shortcode]Baz</b>Qux</div>')
);
}

public function testExtractSplit()
{
$this->markTestSkipped(
'Feature disabled due to https://github.com/silverstripe/silverstripe-framework/issues/5987'
);

// Center splits the current block
$this->assertEqualsIgnoringWhitespace(
Expand All @@ -209,7 +217,9 @@ public function testtExtract() {
'<div>Foo<b>Bar</b></div>Code<div><b>Baz</b>Qux</div>',
$this->parser->parse('<div>Foo<b>Bar[test_shortcode class=center]Code[/test_shortcode]Baz</b>Qux</div>')
);
}

public function testExtractNone() {
// No class means don't extract
$this->assertEqualsIgnoringWhitespace(
'<div>FooCodeBar</div>',
Expand Down

0 comments on commit f314b86

Please sign in to comment.