[BUGFIX] Ignore userTSConfig if not set in getModTSconfig() 02/23702/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Mon, 9 Sep 2013 18:06:17 +0000 (20:06 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 9 Sep 2013 18:53:41 +0000 (20:53 +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/23702
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php

index 9eed7d0..b4e620d 100644 (file)
@@ -2628,6 +2628,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 = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($pageTS_modOptions, $BE_USER_modOptions);
                return $modTSconfig;
        }
@@ -4121,4 +4124,4 @@ class BackendUtility {
                return !empty($GLOBALS['TCA'][$table]['ctrl']['security']['ignoreRootLevelRestriction']);
        }
 }
-?>
+?>
\ No newline at end of file
index dfba55a..d659053 100644 (file)
@@ -684,6 +684,35 @@ class BackendUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $onclickCode = 'var previewWin = window.open(\'' . $alternativeUrl . '\',\'newTYPO3frontendWindow\');';
                $this->assertStringMatchesFormat($onclickCode, Utility\BackendUtility::viewOnClick(NULL, NULL, NULL, NULL, $alternativeUrl, NULL, FALSE));
        }
+
+       /**
+        * @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'));
+       }
+
+
 }
 
-?>
\ No newline at end of file
+?>