[BUGFIX] Ignore userTSConfig if not set in getModTSconfig() 01/23701/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Mon, 9 Sep 2013 18:06:17 +0000 (20:06 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 9 Sep 2013 18:35:42 +0000 (20:35 +0200)
It can happen that settings that are not defined in
userTSConfig can overwrite pageTSConfig settings
with a null value because of the change in #51007

This case is now checked so that in this case
the original pageTSConfig value is preserved.

Resolves: #51871
Releases: 6.0, 6.1, 6.2
Change-Id: I3fa356a1e5aa20716a6bc83f7c76b8b755fc0bbf
Reviewed-on: https://review.typo3.org/23701
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php

index 620e734..6ff8e45 100644 (file)
@@ -2682,6 +2682,9 @@ class BackendUtility {
        static public function getModTSconfig($id, $TSref) {
                $pageTS_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref, self::getPagesTSconfig($id));
                $BE_USER_modOptions = $GLOBALS['BE_USER']->getTSConfig($TSref);
+               if (is_null($BE_USER_modOptions['value'])) {
+                       unset($BE_USER_modOptions['value']);
+               }
                $modTSconfig = GeneralUtility::array_merge_recursive_overrule($pageTS_modOptions, $BE_USER_modOptions);
                return $modTSconfig;
        }
index 425c446..82b6995 100644 (file)
@@ -880,5 +880,34 @@ class BackendUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function replaceMarkersInWhereClauseReturnsValidWhereClause($whereClause, $tsConfig, $expected) {
                $this->assertSame($expected, BackendUtility::replaceMarkersInWhereClause($whereClause, 'dummytable', 'dummyfield', $tsConfig));
        }
+
+       /**
+        * @test
+        */
+       public function getModTSconfigIgnoresValuesFromUserTsConfigIfNoSet() {
+               $completeConfiguration = array(
+                       'value' => 'bar',
+                       'properties' => array(
+                               'permissions.' => array(
+                                       'file.' => array(
+                                               'default.' => array('readAction' => '1'),
+                                               '1.' => array('writeAction' => '1'),
+                                               '0.' => array('readAction' => '0'),
+                                       ),
+                               )
+                       )
+               );
+
+               /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Backend\Utility\BackendUtility $fixture */
+               $fixture = $this->getMock('TYPO3\\CMS\\Backend\\Utility\\BackendUtility', array('getPagesTSconfig'));
+
+               $GLOBALS['BE_USER'] = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
+               $GLOBALS['BE_USER']->expects($this->at(0))->method('getTSConfig')->will($this->returnValue($completeConfiguration));
+               $GLOBALS['BE_USER']->expects($this->at(1))->method('getTSConfig')->will($this->returnValue(array('value' => NULL, 'properties' => NULL)));
+
+               $this->assertSame($completeConfiguration, $fixture->getModTSconfig(42, 'notrelevant'));
+       }
+
+
 }
 ?>