Upgrade typo3 configuration

I got one project which uses helhum/typo3-config-handling.

I therefore needed to adjust the config to return the final result, as
the package expects an array instead of globals.

It also loads config multiple times. I therefore needed to remove
require_once and replace by require. But some code can't be required
multiple times and was moved to dedicated files with require_once.

This package prevents writing back silent upgrades, I therefore needed
to clean up the very old configs for TYPO3 < 10.
This commit is contained in:
Daniel Siepmann 2024-06-13 17:42:43 +02:00
parent 87c5ed4da3
commit e346f5661a
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
16 changed files with 143 additions and 130 deletions

View file

@ -1,18 +1,24 @@
<?php <?php
// Note on using helhum/typo3-config-handling package:
// adjust /src/Xclass/ConfigurationManager.php
// - exportConfiguration() to require this file here.
// - getLocalConfiguration() to require this file here.
date_default_timezone_set('Europe/Berlin'); date_default_timezone_set('Europe/Berlin');
ini_set('timezone', 'Europe/Berlin'); ini_set('timezone', 'Europe/Berlin');
require_once 'SystemSettings.php'; require 'SystemSettings.php';
require_once 'Assets.php'; require 'Assets.php';
require_once 'Gfx.php'; require 'Gfx.php';
require_once 'MailSettings.php'; require 'MailSettings.php';
require_once 'CachingConfigurations.php'; require 'Caching.php';
require_once 'CacheFileBackend.php'; require 'Debugging.php';
require_once 'Debugging.php'; require 'Logging.php';
require_once 'Logging.php'; require 'Autologin.php';
require_once 'Autologin.php'; require __DIR__ . '/client-specific/ClientSpecific.php';
require_once __DIR__ . '/client-specific/ClientSpecific.php'; require 'Extensions.php';
require_once 'ExtensionConfigurations.php';
// Last, as we need client specific db adjustments // Last, as we need client specific db adjustments
require_once 'Database.php'; require 'Database.php';
return $GLOBALS['TYPO3_CONF_VARS'];

View file

@ -1,66 +1,7 @@
<?php <?php
namespace Codappix\CdxAutoLogin; require_once 'AutologinClass.php';
// >= 10.4
if (class_exists(\TYPO3\CMS\Core\Authentication\AbstractAuthenticationService::class) !== false) {
class AutoAuthenticationTypo3Service extends \TYPO3\CMS\Core\Authentication\AbstractAuthenticationService
{
public function getUser()
{
$possibleUsernames = [
'dsiepmann',
'daniel.siepmann',
'daniel_siepmann',
];
foreach ($possibleUsernames as $username) {
$record = $this->fetchUserRecord($username);
if (is_array($record)) {
return $record;
}
}
return [];
}
public function authUser(array $user)
{
return 200;
}
}
}
// < 10.4
if (class_exists(\TYPO3\CMS\Sv\AbstractAuthenticationService\AbstractAuthenticationService::class) !== false) {
class AutoAuthenticationTypo3Service extends \TYPO3\CMS\Sv\AbstractAuthenticationService\AbstractAuthenticationService
{
public function getUser()
{
$possibleUsernames = [
'dsiepmann',
'daniel.siepmann',
'daniel_siepmann',
];
foreach ($possibleUsernames as $username) {
$record = $this->fetchUserRecord($username);
if (is_array($record)) {
return $record;
}
}
return [];
}
public function authUser(array $user)
{
return 200;
}
}
}
// Autologin
if ( if (
class_exists(\Codappix\CdxAutoLogin\AutoAuthenticationTypo3Service::class) class_exists(\Codappix\CdxAutoLogin\AutoAuthenticationTypo3Service::class)
&& ($_COOKIE['das_prevent_login'] ?? false) == false && ($_COOKIE['das_prevent_login'] ?? false) == false
@ -73,7 +14,7 @@ if (
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addService( \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addService(
'sitepackage', 'sitepackage',
'auth', 'auth',
AutoAuthenticationTypo3Service::class, \Codappix\CdxAutoLogin\AutoAuthenticationTypo3Service::class,
[ [
'title' => 'Auto User authentication', 'title' => 'Auto User authentication',
'description' => 'Auto authenticate user with configured username', 'description' => 'Auto authenticate user with configured username',
@ -81,7 +22,7 @@ if (
'available' => true, 'available' => true,
'priority' => 100, 'priority' => 100,
'quality' => 50, 'quality' => 50,
'className' => AutoAuthenticationTypo3Service::class, 'className' => \Codappix\CdxAutoLogin\AutoAuthenticationTypo3Service::class,
] ]
); );
} }

View file

@ -0,0 +1,61 @@
<?php
namespace Codappix\CdxAutoLogin;
// >= 10.4
if (class_exists(\TYPO3\CMS\Core\Authentication\AbstractAuthenticationService::class) !== false) {
class AutoAuthenticationTypo3Service extends \TYPO3\CMS\Core\Authentication\AbstractAuthenticationService
{
public function getUser()
{
$possibleUsernames = [
'dsiepmann',
'daniel.siepmann',
'daniel_siepmann',
];
foreach ($possibleUsernames as $username) {
$record = $this->fetchUserRecord($username);
if (is_array($record)) {
return $record;
}
}
return [];
}
public function authUser(array $user)
{
return 200;
}
}
}
// < 10.4
if (class_exists(\TYPO3\CMS\Sv\AbstractAuthenticationService\AbstractAuthenticationService::class) !== false) {
class AutoAuthenticationTypo3Service extends \TYPO3\CMS\Sv\AbstractAuthenticationService\AbstractAuthenticationService
{
public function getUser()
{
$possibleUsernames = [
'dsiepmann',
'daniel.siepmann',
'daniel_siepmann',
];
foreach ($possibleUsernames as $username) {
$record = $this->fetchUserRecord($username);
if (is_array($record)) {
return $record;
}
}
return [];
}
public function authUser(array $user)
{
return 200;
}
}
}

View file

@ -4,6 +4,8 @@
// Disable some for local development // Disable some for local development
// => Done inside Vim, Vim will delete some files after editing // => Done inside Vim, Vim will delete some files after editing
require_once 'CachingFileBackend.php';
// Extensions // Extensions
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['thuecat_fetchdata']['backend'] = \Codappix\CdxFileBackend\FileBackend::class; $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['thuecat_fetchdata']['backend'] = \Codappix\CdxFileBackend\FileBackend::class;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['thuecat_fetchdata']['options'] = [ $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['thuecat_fetchdata']['options'] = [
@ -27,10 +29,16 @@ if (
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['hash']['options']['compression']); unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['hash']['options']['compression']);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pages']['backend'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pages']['backend'] =
\Codappix\CdxFileBackend\FileBackend::class; \Codappix\CdxFileBackend\FileBackend::class;
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pages']['options']['compression']); unset(
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pages']['options']['compression'],
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pages']['options']['tokenName'],
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pagesection']['backend'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pagesection']['backend'] =
\Codappix\CdxFileBackend\FileBackend::class; \Codappix\CdxFileBackend\FileBackend::class;
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pagesection']['options']['compression']); unset(
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pagesection']['options']['compression'],
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pagesection']['options']['tokenName'],
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['imagesizes']['backend'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['imagesizes']['backend'] =
\Codappix\CdxFileBackend\FileBackend::class; \Codappix\CdxFileBackend\FileBackend::class;
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['imagesizes']['options']['compression']); unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['imagesizes']['options']['compression']);
@ -41,12 +49,25 @@ if (
} else { } else {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_rootline']['backend'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_rootline']['backend'] =
\Codappix\CdxFileBackend\FileBackend::class; \Codappix\CdxFileBackend\FileBackend::class;
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pagesection']['options']['compression']);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pagesection']['backend'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pagesection']['backend'] =
\Codappix\CdxFileBackend\FileBackend::class; \Codappix\CdxFileBackend\FileBackend::class;
unset(
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pagesection']['options']['compression'],
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pagesection']['options']['tokenName'],
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_hash']['backend'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_hash']['backend'] =
\Codappix\CdxFileBackend\FileBackend::class; \Codappix\CdxFileBackend\FileBackend::class;
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pages']['options']['compression']); unset(
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_hash']['options']['compression'],
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_hash']['options']['tokenName'],
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pages']['backend'] = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pages']['backend'] =
\Codappix\CdxFileBackend\FileBackend::class; \Codappix\CdxFileBackend\FileBackend::class;
unset(
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pages']['options']['compression'],
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pages']['options']['tokenName'],
);
} }

View file

@ -1,25 +1,13 @@
<?php <?php
// Database $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'] = array_merge($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'] ?? [], [
$GLOBALS['TYPO3_CONF_VARS']['DB']['username'] = 'dev'; 'dbname' => $typo_db,
$GLOBALS['TYPO3_CONF_VARS']['DB']['password'] = 'dev'; 'host' => '127.0.0.1',
// Looks like TYPO3 doesn't work with my socket inside the install tool ... 'password' => 'dev',
$GLOBALS['TYPO3_CONF_VARS']['DB']['host'] = '127.0.0.1'; 'user' => 'dev',
// $GLOBALS['TYPO3_CONF_VARS']['DB']['host'] = ''; 'port' => null,
$GLOBALS['TYPO3_CONF_VARS']['DB']['socket'] = '/var/run/mysqld/mysqld.sock'; 'socket' => '/var/run/mysqld/mysqld.sock',
$GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'] = true; 'unix_socket' => '/var/run/mysqld/mysqld.sock',
// Auto set for simple instances via http host. or env from apache This allows
// to set it at one place for the whole project if multiple domains are used
$GLOBALS['TYPO3_CONF_VARS']['DB']['database'] = $typo_db;
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'] = array_merge($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'], [
'dbname' => $GLOBALS['TYPO3_CONF_VARS']['DB']['database'],
'host' => $GLOBALS['TYPO3_CONF_VARS']['DB']['host'],
'password' => $GLOBALS['TYPO3_CONF_VARS']['DB']['password'],
'user' => $GLOBALS['TYPO3_CONF_VARS']['DB']['username'],
'port' => $GLOBALS['TYPO3_CONF_VARS']['DB']['port'] ?? null,
'socket' => $GLOBALS['TYPO3_CONF_VARS']['DB']['socket'],
'unix_socket' => $GLOBALS['TYPO3_CONF_VARS']['DB']['socket'],
'driver' => 'mysqli', 'driver' => 'mysqli',
'charset' => 'utf8mb4', 'charset' => 'utf8mb4',
'tableoptions' => [ 'tableoptions' => [

View file

@ -1,20 +1,14 @@
<?php <?php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['belogErrorReporting'] = 1; $GLOBALS['TYPO3_CONF_VARS']['SYS']['belogErrorReporting'] = 1;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG'] = true;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG'] = true;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'] = 'error_log,,0;'; $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'] = 'error_log,,0;';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'] = 0; $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'] = 0;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = '*'; $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = '*';
$GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] = true; $GLOBALS['TYPO3_CONF_VARS']['BE']['debug'] = true;
$GLOBALS['TYPO3_CONF_VARS']['FE']['debug'] = true; $GLOBALS['TYPO3_CONF_VARS']['FE']['debug'] = true;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'] = true;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'] = 1; $GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'] = 1;
// Disable by default // Disable by default
$GLOBALS['TYPO3_CONF_VARS']['BE']['lang']['debug'] = false;
$GLOBALS['TYPO3_CONF_VARS']['BE']['languageDebug'] = false; $GLOBALS['TYPO3_CONF_VARS']['BE']['languageDebug'] = false;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors'] = E_ALL & ~ (E_NOTICE | E_DEPRECATED); $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors'] = E_ALL & ~ (E_NOTICE | E_DEPRECATED);

View file

@ -1,8 +1,5 @@
<?php <?php
$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor'] = 'ImageMagick'; $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor'] = 'ImageMagick';
$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] = 'im6'; $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path'] = getenv('IMAGEMAGICK_PATH') ?: '/usr/bin/';
$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'] = getenv('IMAGEMAGICK_PATH') ?: '/usr/bin/'; $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path_lzw'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path'];
$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'];
$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'];
$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path_lzw'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'];

View file

@ -1,22 +1,6 @@
<?php <?php
namespace Codappix\CdxLogging; require_once 'LoggingUriProcessor.php';
use TYPO3\CMS\Core\Log\LogRecord;
use TYPO3\CMS\Core\Log\Processor\AbstractProcessor;
use TYPO3\CMS\Core\Log\Processor\ProcessorInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class UriProcessor extends AbstractProcessor implements ProcessorInterface
{
public function processLogRecord(LogRecord $logRecord)
{
$logRecord->addData([
'URI' => GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'),
]);
return $logRecord;
}
}
$GLOBALS['TYPO3_CONF_VARS']['LOG']['das']['writerConfiguration'] = [ $GLOBALS['TYPO3_CONF_VARS']['LOG']['das']['writerConfiguration'] = [
\TYPO3\CMS\Core\Log\LogLevel::DEBUG => [ \TYPO3\CMS\Core\Log\LogLevel::DEBUG => [

View file

@ -0,0 +1,20 @@
<?php
namespace Codappix\CdxLogging;
use TYPO3\CMS\Core\Log\LogRecord;
use TYPO3\CMS\Core\Log\Processor\AbstractProcessor;
use TYPO3\CMS\Core\Log\Processor\ProcessorInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class UriProcessor extends AbstractProcessor implements ProcessorInterface
{
public function processLogRecord(LogRecord $logRecord)
{
$logRecord->addData([
'URI' => GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'),
]);
return $logRecord;
}
}

View file

@ -15,10 +15,6 @@
} }
'); ');
$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] = true;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'] = '';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyTunnel'] = false;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['proxy_host'] = ''; $GLOBALS['TYPO3_CONF_VARS']['SYS']['proxy_host'] = '';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['proxy_port'] = ''; $GLOBALS['TYPO3_CONF_VARS']['SYS']['proxy_port'] = '';
@ -56,3 +52,8 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] = '*.localhost DEVELOPMENT';
if (isset($GLOBALS['_SERVER']['HTTP_HOST'])) { if (isset($GLOBALS['_SERVER']['HTTP_HOST'])) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] = $GLOBALS['_SERVER']['HTTP_HOST'] . ' DEVELOPMENT'; $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] = $GLOBALS['_SERVER']['HTTP_HOST'] . ' DEVELOPMENT';
} }
// TODO: Check readme/wiki and use provided key for project only?
if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) === false) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 'some test key';
}