Commit 7f33ef07 authored by Marc Egger's avatar Marc Egger
Browse files

T3v10: replace deprecated system_language_uid and move beUserLoggedIn() out of Config.php

parent a7d284e6
Pipeline #4324 failed with stages
in 4 minutes and 23 seconds
......@@ -24,7 +24,7 @@
namespace IMATHUZH\Qfq\Core\Report;
use IMATHUZH\Qfq\Core\Evaluate;
use IMATHUZH\Qfq\Core\Store\T3Info;
/**
......@@ -160,15 +160,7 @@ class Variables {
$arr["page_id"] = $GLOBALS["TSFE"]->id;
$arr["page_type"] = $GLOBALS["TSFE"]->type;
$arr["page_language_uid"] = $GLOBALS["TSFE"]->sys_language_uid; // DEPRECATED
/** ?CR
* TODO: Remove page_language_uid if not used or migrate to new
*
* Deprecation: #85543 - Language-related properties in TypoScriptFrontendController and PageRepository
* Migration:
* $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
* (previously known as TSFE->sys_language_uid)
*/
$arr["page_language_uid"] = T3Info::getLanguageId();
}
......
......@@ -200,7 +200,7 @@ class Config {
{
$configT3qfq = array();
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][EXT_KEY])) {
// Typo3 version >=10
// Typo3 version >=9
$configT3qfq = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][EXT_KEY];
$configT3qfq[SYSTEM_DB_NAME_T3] = self::getDbName($GLOBALS['TYPO3_CONF_VARS']['DB']);
$configT3qfq[SYSTEM_PW_HASHING_CLASS] = $GLOBALS['TYPO3_CONF_VARS']['BE']['passwordHashing']['className'];
......@@ -215,7 +215,7 @@ class Config {
$cwdToTypo3ConfigFile = Path::cwdToApp(Path::APP_TO_TYPO3_CONF, CONFIG_T3);
$configT3 = HelperFile::include($cwdToTypo3ConfigFile);
if (isset($configT3['EXTENSIONS'][EXT_KEY])) {
// Typo3 version >=10
// Typo3 version >=9
$configT3qfq = $configT3['EXTENSIONS'][EXT_KEY];
$configT3qfq[SYSTEM_PW_HASHING_CLASS] = $configT3['BE']['passwordHashing']['className'];
// NOTE: This does not use the official API to access Typo3 password hashing. Here is the official API: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/PasswordHashing/
......@@ -541,7 +541,7 @@ class Config {
*/
private static function adjustConfig(array $config) {
$config[SYSTEM_SHOW_DEBUG_INFO] = self::adjustConfigDebugInfoAuto($config[SYSTEM_SHOW_DEBUG_INFO], self::beUserLoggedIn());
$config[SYSTEM_SHOW_DEBUG_INFO] = self::adjustConfigDebugInfoAuto($config[SYSTEM_SHOW_DEBUG_INFO], T3Info::beUserLoggedIn());
// In case the database credentials are given in the old style: copy them to the new style
if (!isset($config[SYSTEM_DB_1_USER]) && isset($config[SYSTEM_DB_USER])) {
......@@ -574,24 +574,6 @@ class Config {
return $value;
}
/**
* Check if there is a Typo3 beUser is logged in. This is only possible if QFQ is called via T3, not via API
*
* @return bool true: current Browser session is a logged in BE User.
*/
public static function beUserLoggedIn() {
if (class_exists('TYPO3\CMS\Core\Context\Context')) {
// Typo3 version >=10
$context = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class);
return $context->getPropertyFromAspect('backend.user', 'isLoggedIn');
} elseif (!empty($GLOBALS["TSFE"]->beUserLogin) && $GLOBALS["TSFE"]->beUserLogin === true) {
// Typo3 version <=8
return true;
}
return false;
}
/**
* Set automatic filled values
*
......
......@@ -710,7 +710,7 @@ class Store {
}
}
$t3varsArray[TYPO3_BE_USER_LOGGED_IN] = Config::beUserLoggedIn() ? 'yes' : 'no';
$t3varsArray[TYPO3_BE_USER_LOGGED_IN] = T3Info::beUserLoggedIn() ? 'yes' : 'no';
$t3varsString = KeyValueStringParser::unparse($t3varsArray, '=', '&');
$t3sip = self::$sip->queryStringToSip($t3varsString, RETURN_SIP);
......
......@@ -40,20 +40,50 @@ class T3Info {
$t3vars[TYPO3_PAGE_TYPE] = isset($GLOBALS["TSFE"]->type) ? $GLOBALS["TSFE"]->type : '';
$t3vars[TYPO3_PAGE_LANGUAGE] = isset($GLOBALS["TSFE"]->sys_language_uid) ? $GLOBALS["TSFE"]->sys_language_uid : ''; // DEPRECATED
/** ?CR
* TODO: Remove page_language_uid if not used or migrate to new
*
* Deprecation: #85543 - Language-related properties in TypoScriptFrontendController and PageRepository
* Migration:
* $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
* (previously known as TSFE->sys_language_uid)
*/
$t3vars[TYPO3_BE_USER_LOGGED_IN] = Config::beUserLoggedIn() ? 'yes' : 'no';
$t3vars[TYPO3_PAGE_LANGUAGE] = self::getLanguageId();
$t3vars[TYPO3_BE_USER_LOGGED_IN] = self::beUserLoggedIn() ? 'yes' : 'no';
$t3vars[TYPO3_BE_USER] = isset($GLOBALS["BE_USER"]->user["username"]) ? $GLOBALS["BE_USER"]->user["username"] : '';
return $t3vars;
}
/**
* Returns the page language uid. This is only possible if QFQ is called via T3, not via API.
*
* @return string
*/
public static function getLanguageId()
{
if (class_exists('TYPO3\CMS\Core\Context\Context')) {
// Typo3 version >=9
$context = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class);
$languageAspect = $context->getAspect('language');
// (previously known as TSFE->sys_language_uid)
return $languageAspect->getId();
} elseif (isset($GLOBALS["TSFE"]->sys_language_uid)) {
// Typo3 version <=8
return $GLOBALS["TSFE"]->sys_language_uid;
}
return '';
}
/**
* Check if there is a Typo3 beUser is logged in. This is only possible if QFQ is called via T3, not via API
*
* @return bool true: current Browser session is a logged in BE User.
*/
public static function beUserLoggedIn() {
if (class_exists('TYPO3\CMS\Core\Context\Context')) {
// Typo3 version >=9
$context = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class);
return $context->getPropertyFromAspect('backend.user', 'isLoggedIn');
} elseif (!empty($GLOBALS["TSFE"]->beUserLogin) && $GLOBALS["TSFE"]->beUserLogin === true) {
// Typo3 version <=8
return true;
}
return false;
}
}
\ No newline at end of file
......@@ -60,7 +60,7 @@ class T3Handler {
$t3Hasher = self::getT3HashingInstance(); //implements interface: TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface
if (!is_null($t3Hasher)) {
// Typo3 version >=10
// Typo3 version >=9
$saltedPassword = $t3Hasher->getHashedPassword($newPassword);
// NOTE: This does not use the official API to access Typo3 password hashing. Here is the official API: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/PasswordHashing/
......@@ -109,7 +109,7 @@ class T3Handler {
$t3Hasher = self::getT3HashingInstance(); //implements interface: TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface
if (!is_null($t3Hasher)) {
// Typo3 version >=10
// Typo3 version >=9
$success = $t3Hasher->checkPassword($password, $saltedPassword);
// NOTE: This does not use the official API to access Typo3 password hashing. Here is the official API: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/PasswordHashing/
......@@ -167,7 +167,7 @@ class T3Handler {
if (!class_exists('\TYPO3\CMS\Core\Utility\GeneralUtility')) {
if (file_exists(Path::absoluteApp('vendor/autoload.php'))) {
// Typo3 version >=10
// Typo3 version >=9
require Path::absoluteApp('vendor/autoload.php');
} else {
// Typo3 version <=8
......@@ -211,7 +211,7 @@ class T3Handler {
// Same as $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['qfq']
$configT3 = $configurationManager->getLocalConfiguration();
if (isset($configT3['EXTENSIONS'][EXT_KEY])) {
// Typo3 version >=10
// Typo3 version >=9
$configQfq = $configT3['EXTENSIONS'][EXT_KEY];
} else {
// Typo3 version <=8
......@@ -223,7 +223,7 @@ class T3Handler {
// Prepare
if (isset($configT3['EXTENSIONS'][EXT_KEY])) {
// Typo3 version >=10
// Typo3 version >=9
$configT3['EXTENSIONS'][EXT_KEY] = $configQfq;
} else {
// Typo3 version <=8
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment