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 e1ae40c2d1
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
13 changed files with 120 additions and 126 deletions

View file

@ -1,18 +1,24 @@
<?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');
ini_set('timezone', 'Europe/Berlin');
require_once 'SystemSettings.php';
require_once 'Assets.php';
require_once 'Gfx.php';
require_once 'MailSettings.php';
require_once 'CachingConfigurations.php';
require_once 'CacheFileBackend.php';
require_once 'Debugging.php';
require_once 'Logging.php';
require_once 'Autologin.php';
require_once __DIR__ . '/client-specific/ClientSpecific.php';
require_once 'ExtensionConfigurations.php';
require 'SystemSettings.php';
require 'Assets.php';
require 'Gfx.php';
require 'MailSettings.php';
require 'Caching.php';
require 'Debugging.php';
require 'Logging.php';
require 'Autologin.php';
require __DIR__ . '/client-specific/ClientSpecific.php';
require 'Extensions.php';
// 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
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 (
class_exists(\Codappix\CdxAutoLogin\AutoAuthenticationTypo3Service::class)
&& ($_COOKIE['das_prevent_login'] ?? false) == false
@ -73,7 +14,7 @@ if (
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addService(
'sitepackage',
'auth',
AutoAuthenticationTypo3Service::class,
\Codappix\CdxAutoLogin\AutoAuthenticationTypo3Service::class,
[
'title' => 'Auto User authentication',
'description' => 'Auto authenticate user with configured username',
@ -81,7 +22,7 @@ if (
'available' => true,
'priority' => 100,
'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
// => Done inside Vim, Vim will delete some files after editing
require_once 'CachingFileBackend.php';
// Extensions
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['thuecat_fetchdata']['backend'] = \Codappix\CdxFileBackend\FileBackend::class;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['thuecat_fetchdata']['options'] = [

View file

@ -1,25 +1,13 @@
<?php
// Database
$GLOBALS['TYPO3_CONF_VARS']['DB']['username'] = 'dev';
$GLOBALS['TYPO3_CONF_VARS']['DB']['password'] = 'dev';
// Looks like TYPO3 doesn't work with my socket inside the install tool ...
$GLOBALS['TYPO3_CONF_VARS']['DB']['host'] = '127.0.0.1';
// $GLOBALS['TYPO3_CONF_VARS']['DB']['host'] = '';
$GLOBALS['TYPO3_CONF_VARS']['DB']['socket'] = '/var/run/mysqld/mysqld.sock';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'] = true;
// 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'],
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'] = array_merge($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'] ?? [], [
'dbname' => $typo_db,
'host' => '127.0.0.1',
'password' => 'dev',
'user' => 'dev',
'port' => null,
'socket' => '/var/run/mysqld/mysqld.sock',
'unix_socket' => '/var/run/mysqld/mysqld.sock',
'driver' => 'mysqli',
'charset' => 'utf8mb4',
'tableoptions' => [

View file

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

View file

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

View file

@ -1,22 +1,6 @@
<?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;
}
}
require_once 'LoggingUriProcessor.php';
$GLOBALS['TYPO3_CONF_VARS']['LOG']['das']['writerConfiguration'] = [
\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_port'] = '';
@ -56,3 +52,8 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] = '*.localhost DEVELOPMENT';
if (isset($GLOBALS['_SERVER']['HTTP_HOST'])) {
$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';
}