TYPO3 v15 dev-main snapshot ()

This commit is contained in:
2026-08-10 22:31:09 +02:00
commit af8cc155b5
6818 changed files with 642608 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\SysLog;
/**
* A class defining non type specific actions
*/
class Action
{
public const UNDEFINED = 0;
}
+26
View File
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\SysLog\Action;
/**
* A class defining possible Cache actions
*/
class Cache
{
public const CLEAR = 1;
}
+34
View File
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\SysLog\Action;
/**
* A class defining possible Database actions
*/
class Database
{
public const INSERT = 1;
public const UPDATE = 2;
public const DELETE = 3;
public const MOVE = 4;
public const CHECK = 5;
public const LOCALIZE = 6;
public const VERSIONIZE = 7;
public const PUBLISH = 8;
public const DISCARD = 9;
}
+39
View File
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\SysLog\Action;
/**
* A class defining possible File actions
*/
class File
{
public const UPLOAD = 1;
public const COPY = 2;
public const MOVE = 3;
public const DELETE = 4;
public const RENAME = 5;
public const NEW_FOLDER = 6;
/*
* The constant is not in use but the xlf file tells that 7 represents unzip
* @see https://github.com/typo3/typo3/blob/master/typo3/sysext/belog/Resources/Private/Language/locallang.xlf#L267
*/
public const UNZIP = 7;
public const NEW_FILE = 8;
public const EDIT = 9;
}
+31
View File
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\SysLog\Action;
/**
* A class defining possible Login actions
*/
class Login
{
public const LOGIN = 1;
public const LOGOUT = 2;
public const ATTEMPT = 3;
public const SEND_FAILURE_WARNING_EMAIL = 4;
public const PASSWORD_RESET_REQUEST = 5;
public const PASSWORD_RESET_ACCOMPLISHED = 6;
}
+26
View File
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\SysLog\Action;
/**
* A class defining possible Setting actions
*/
class Setting
{
public const CHANGE = 1;
}
+29
View File
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\SysLog\Action;
/**
* A class defining possible Site actions
*/
class Site
{
public const CREATE = 1;
public const UPDATE = 2;
public const RENAME = 3;
public const DELETE = 4;
}
+30
View File
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\SysLog;
/**
* A class defining possible error types
*/
class Error
{
public const MESSAGE = 0;
public const USER_ERROR = 1;
public const SYSTEM_ERROR = 2;
public const SECURITY_NOTICE = 3;
public const WARNING = 4;
}
@@ -0,0 +1,184 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\SysLog\Repository;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Security\PermissionSet\PrincipalContext;
use TYPO3\CMS\Core\Security\PermissionSet\PrincipalRole;
use TYPO3\CMS\Core\Security\PermissionSet\ProcessingContext;
use TYPO3\CMS\Core\SysLog\Type;
/**
* Repository for writing system log entries to the database.
*
* Provides methods to create log entries in the sys_log table,
* tracking user actions, errors, and system events.
*
* @internal
*/
#[Autoconfigure(public: true)]
final readonly class LogEntryRepository
{
public function __construct(private ConnectionPool $connectionPool) {}
/**
* Legacy wrapper for `writeLogEntry`, invoked with the current backend user.
*
* This method extracts the principal and processing context from the BackendUserAuthentication
* object and delegates to writeLogEntry(). It automatically handles user impersonation
* (switch user mode) by including the original user ID in the log data.
*
* @internal might be removed during TYPO3 v14 development
*/
public function writeLogEntryForBackendUser(
BackendUserAuthentication $backendUser,
int $type,
int $action,
int $error,
string $details,
array $data,
string $tableName = '',
int|string $recordUid = '',
int $eventPid = -1,
): int {
if ($impersonatedBy = $backendUser->getOriginalUserIdWhenInSwitchUserMode()) {
$impersonatedBy = new PrincipalContext(
// @todo role is hardcoded here, but should be resolved
role: PrincipalRole::ADMIN,
id: $impersonatedBy,
);
} else {
$impersonatedBy = null;
}
$principalContext = new PrincipalContext(
role: $backendUser->getRole(),
id: $backendUser->getUserId() ?? 0,
impersonatedBy: $impersonatedBy,
);
$processingContext = new ProcessingContext(
workspaceId: $backendUser->workspace,
);
return $this->writeLogEntry(
$principalContext,
$processingContext,
$type,
$action,
$error,
$details,
$data,
$tableName,
$recordUid,
$eventPid
);
}
/**
* Writes an entry to the system log (sys_log table).
*
* This method creates a log entry tracking user actions, errors, and system events.
* The log entry includes context about the principal (user), workspace, and optionally
* the database record affected by the action.
*
* @param PrincipalContext $principalContext The user/principal context that triggered the log entry, including user ID and role
* @param ProcessingContext $processingContext The processing context, including workspace ID where the action occurred
* @param int $type Type of action that created the log entry. Common types include:
* 1 (DB) for database operations, 2 (FILE) for file operations,
* 3 (CACHE) for cache operations, 4 (EXTENSION) for extension actions,
* 5 (ERROR) for errors, 255 (LOGIN) for login/logout events.
* See \TYPO3\CMS\Core\SysLog\Type constants.
* @param int $action Specific action ID within the type category. The meaning depends on $type.
* Use 0 when no sub-categorization applies.
* @param int $error Severity level: 0 = informational message, 1 = warning (user problem),
* 2 = system error (should not happen), 3 = security notice (for admins)
* @param string $details The log message text. May contain sprintf-style placeholders (%s, %d, etc.)
* that will be substituted with values from $data array.
* @param array $data Additional data for the log entry. If provided, the first 5 elements (keys 0-4)
* will be used to substitute placeholders in $details via sprintf.
* Special key 'originalUser' is set automatically when user impersonation is active.
* @param string $tableName Database table name of the record affected by this action (used by DataHandler).
* @param int|string $recordUid UID of the record affected by this action (used by DataHandler).
* @param int $eventPid Page UID where the event occurred. Used to filter log entries by page.
* Use -1 for global events not tied to a specific page.
* @param ServerRequestInterface|null $request The request object that triggered the log entry.
* @return int The UID of the created log entry.
*/
public function writeLogEntry(
PrincipalContext $principalContext,
ProcessingContext $processingContext,
int $type,
int $action,
int $error,
string $details,
array $data,
string $tableName = '',
int|string $recordUid = '',
int $eventPid = -1,
?ServerRequestInterface $request = null
): int {
$userId = $principalContext->id;
$workspaceId = $processingContext->workspaceId;
if ($principalContext->impersonatedBy !== null) {
$data['originalUser'] = $principalContext->impersonatedBy->id;
}
$request ??= $GLOBALS['TYPO3_REQUEST'] ?? null;
$connection = $this->connectionPool->getConnectionForTable('sys_log');
$connection->insert(
'sys_log',
[
'userid' => $userId,
'type' => $type,
'channel' => Type::toChannel($type),
'level' => Type::toLevel($type),
'action' => $action,
'error' => $error,
'details' => $details,
'log_data' => $data !== [] ? json_encode($data) : '',
'tablename' => $tableName,
'recuid' => is_int($recordUid) ? $recordUid : 0,
'IP' => $request?->getAttribute('normalizedParams')?->getRemoteAddress() ?? '',
'tstamp' => $GLOBALS['EXEC_TIME'] ?? time(),
'event_pid' => $eventPid,
'workspace' => $workspaceId,
],
[
Connection::PARAM_INT,
Connection::PARAM_INT,
Connection::PARAM_STR,
Connection::PARAM_STR,
Connection::PARAM_INT,
Connection::PARAM_INT,
Connection::PARAM_STR,
Connection::PARAM_STR,
Connection::PARAM_STR,
Connection::PARAM_INT,
Connection::PARAM_STR,
Connection::PARAM_INT,
Connection::PARAM_INT,
Connection::PARAM_INT,
]
);
return (int)$connection->lastInsertId();
}
}
+85
View File
@@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\SysLog;
use Psr\Log\LogLevel;
/**
* A class defining possible logging types.
*
* @internal The logging type system is moving towards PSR-3-defined log levels and channels, this class might get removed without any further notice from TYPO3 v12.0. on.
*/
class Type
{
public const DB = 1;
public const FILE = 2;
public const CACHE = 3;
public const EXTENSION = 4;
public const ERROR = 5;
public const SITE = 6;
public const SETTING = 254;
public const LOGIN = 255;
private static array $channelMap = [
self::DB => 'content',
self::FILE => 'file',
self::CACHE => 'default',
self::EXTENSION => 'default',
self::ERROR => 'php',
self::SITE => 'site',
self::SETTING => 'default',
self::LOGIN => 'user',
];
private static array $levelMap = [
self::DB => LogLevel::INFO,
self::FILE => LogLevel::INFO,
self::CACHE => LogLevel::INFO,
self::EXTENSION => LogLevel::INFO,
self::ERROR => LogLevel::ERROR,
self::SITE => LogLevel::INFO,
self::SETTING => LogLevel::INFO,
self::LOGIN => LogLevel::INFO,
];
/**
* @internal
*/
public static function levelMap(): array
{
return self::$levelMap;
}
/**
* @internal
*/
public static function channelMap(): array
{
return self::$channelMap;
}
public static function toChannel(int $type): string
{
return self::$channelMap[$type] ?? 'default';
}
public static function toLevel(int $type): string
{
return self::$levelMap[$type] ?? LogLevel::INFO;
}
}