Accessing one of these properties will raise a PHP warning.
Calling the method :php:`fetchSessionData()` will cause a PHP fatal error.
+Moreover it is not possible anymore to use the getData function from within TypoScript
+to access session data. This functionality is replaced by a new API. (see :issue:`80154`)
Affected Installations
======================
--- /dev/null
+.. include:: ../../Includes.txt
+
+=============================================
+Feature: #80154 - Retrieve session data in TS
+=============================================
+
+See :issue:`80154`
+
+Description
+===========
+
+As the session API has been modified, it is no longer possible to access
+session data from TypoScript by accessing the formerly public property of
+the fe_user with:
+
+.. code-block:: typoscript
+
+ page.10 = TEXT
+ page.10.data = TSFE:fe_user|sesData|myext|mydata
+
+
+This is being replaced by a more direct way, which allows for the same functionality:
+
+.. code-block:: typoscript
+
+ page.10 = TEXT
+ page.10.data = session:myext|mydata
+
+.. index:: Frontend, TypoScript
\ No newline at end of file
}
}
break;
+ case 'session':
+ $keyParts = GeneralUtility::trimExplode('|', $key, true);
+ $sessionKey = array_shift($keyParts);
+ $retVal = $this->getTypoScriptFrontendController()->fe_user->getSessionData($sessionKey);
+ foreach ($keyParts as $keyPart) {
+ if (is_object($retVal)) {
+ $retVal = $retVal->{$keyPart};
+ } elseif (is_array($retVal)) {
+ $retVal = $retVal[$keyPart];
+ } else {
+ $retVal = '';
+ break;
+ }
+ }
+ if (!is_scalar($retVal)) {
+ $retVal = '';
+ }
+ break;
}
}
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'])) {
use TYPO3\CMS\Core\TypoScript\TemplateService;
use TYPO3\CMS\Core\Utility\DebugUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
use TYPO3\CMS\Frontend\ContentObject\AbstractContentObject;
use TYPO3\CMS\Frontend\ContentObject\CaseContentObject;
use TYPO3\CMS\Frontend\ContentObject\ContentContentObject;
}
/**
+ * Checks if getData() works with type "session"
+ *
+ * @test
+ */
+ public function getDataWithTypeSession()
+ {
+ $frontendUser = $this->getMockBuilder(FrontendUserAuthentication::class)
+ ->setMethods(['getSessionData'])
+ ->getMock();
+ $frontendUser->expects($this->once())->method('getSessionData')->with('myext')->willReturn([
+ 'mydata' => [
+ 'someValue' => 42,
+ ],
+ ]);
+ $GLOBALS['TSFE']->fe_user = $frontendUser;
+
+ $this->assertEquals(42, $this->subject->getData('session:myext|mydata|someValue'));
+ }
+
+ /**
* Checks if getData() works with type "level"
*
* @test