[BUGFIX] Flaky references in TypoScript parsing 77/48777/7
authorOliver Hader <oliver@typo3.org>
Sat, 2 Jul 2016 15:52:10 +0000 (17:52 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 15 Jul 2016 19:03:36 +0000 (21:03 +0200)
The patch from forge issue #76323 triggers errors at least
on some PHP versions. The change is reverted with this patch
and an acceptance test is added to verify correct behavior.

Resolves: #76919
Related: #76323
Releases: master
Change-Id: I2515d3a71c96f3d6e54e04af52bb8cbffbd69d6d
Reviewed-on: https://review.typo3.org/48777
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php
typo3/sysext/core/Tests/Functional/TypoScript/Parser/TypoScriptParserTest.php [new file with mode: 0644]

index 2b4be20..06e5eb1 100644 (file)
@@ -454,7 +454,9 @@ class TypoScriptParser
                                             } else {
                                                 $res = $this->getVal($theVal, $this->setup);
                                             }
-                                            $this->setVal($objStrName, $setup, $res, 1);
+                                            // unserialize(serialize(...)) may look stupid but is needed because of some reference issues.
+                                            // See forge issue #76919 and functional test hasFlakyReferences()
+                                            $this->setVal($objStrName, $setup, unserialize(serialize($res)), 1);
                                             break;
                                         case '>':
                                             if ($this->syntaxHighLight) {
diff --git a/typo3/sysext/core/Tests/Functional/TypoScript/Parser/TypoScriptParserTest.php b/typo3/sysext/core/Tests/Functional/TypoScript/Parser/TypoScriptParserTest.php
new file mode 100644 (file)
index 0000000..01a9069
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Functional\TypoScript\Parser;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Functional test for TypoScriptParser
+ */
+class TypoScriptParserTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase
+{
+    /**
+     * This tests triggers an error if the serialize(unserialize())) call
+     * within TypoScriptParser is removed. See forge issue #76919
+     *
+     * @test
+     */
+    public function hasFlakyReferences()
+    {
+        $typoScript = implode(LF, [
+            '',
+            '[GLOBAL]',
+            'RTE.default.proc.entryHTMLparser_db = 1',
+            'RTE.default.proc.entryHTMLparser_db {',
+                'tags {',
+                '}',
+            '}',
+
+            'RTE.default.FE < RTE.default',
+
+            'RTE.default.enableWordClean = 1',
+            'RTE.default.enableWordClean.HTMLparser < RTE.default.proc.entryHTMLparser_db',
+            '',
+        ]);
+
+        $typoScriptParser = new \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser();
+        $typoScriptParser->parse($typoScript);
+        $res = ['TSconfig' => $typoScriptParser->setup];
+        // The issue only pops up if the TS was cached. This call simulates the unserialize(serialize())
+        // call done by the cache framework to trigger the issue.
+        $res = unserialize(serialize($res));
+        $res['TSconfig']['RTE.']['default.']['FE.']['proc.']['entryHTMLparser_db.']['tags.'] = 'This';
+        $this->assertEquals(array(), $res['TSconfig']['RTE.']['default.']['proc.']['entryHTMLparser_db.']['tags.']);
+    }
+}