From f314b86ad804b021cda255e4645e99e8d971fa8a Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 21 Dec 2016 18:55:00 +1300 Subject: [PATCH] BUG Temp disable shortcode SPLIT behaviour due to crash (#6436) Fixes #5987 --- parsers/ShortcodeParser.php | 3 ++- tests/parsers/ShortcodeParserTest.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/parsers/ShortcodeParser.php b/parsers/ShortcodeParser.php index be3b52d4c..b3e7076a8 100644 --- a/parsers/ShortcodeParser.php +++ b/parsers/ShortcodeParser.php @@ -584,7 +584,8 @@ class ShortcodeParser extends Object { $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) { diff --git a/tests/parsers/ShortcodeParserTest.php b/tests/parsers/ShortcodeParserTest.php index 85dcaa3b4..796d06478 100644 --- a/tests/parsers/ShortcodeParserTest.php +++ b/tests/parsers/ShortcodeParserTest.php @@ -185,7 +185,8 @@ class ShortcodeParserTest extends SapphireTest { $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
FooBar
', @@ -197,6 +198,13 @@ class ShortcodeParserTest extends SapphireTest { 'Code
FooBarBazQux
', $this->parser->parse('
FooBar[test_shortcode class=left]Code[/test_shortcode]BazQux
') ); + } + + public function testExtractSplit() + { + $this->markTestSkipped( + 'Feature disabled due to https://github.com/silverstripe/silverstripe-framework/issues/5987' + ); // Center splits the current block $this->assertEqualsIgnoringWhitespace( @@ -209,7 +217,9 @@ class ShortcodeParserTest extends SapphireTest { '
FooBar
Code
BazQux
', $this->parser->parse('
FooBar[test_shortcode class=center]Code[/test_shortcode]BazQux
') ); + } + public function testExtractNone() { // No class means don't extract $this->assertEqualsIgnoringWhitespace( '
FooCodeBar
',