Skip to content
Snippets Groups Projects
Commit d9323c00 authored by Thomas Hohn's avatar Thomas Hohn Committed by Stefan Bürk
Browse files

[BUGFIX] Mitigate exceptions in `LogDataTrait::formatLogDetailsStatic`

`LogDataTrait::formatLogDetailsStatic()` simple used `vsprintf()`
in case that the string contains any `%` characters and throws
either a `\ValueError` or `\ArgumentCountError` depending if no
value exists or the count does not match.

It is not reliable and implement additional lexing here to avoid
the exception by not calling `vsprintf()` upfront.

This change calls `vsprintf()` and handles the mentioned exceptions
and use the fallback handling in case exception has been thrown as
a simplefied approach. Tests are added to cover legacy, mixed and
new log format option along with static and instanced method calls.

Note that a minor inline PHP DocBlock annotation has been added
in `LogDataTrait` to mitigate detection issues of PHPStan, which
allows now to remove baseline ignore patterns in the same run.

Used command(s):

> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #103711
Releases: main, 12.4
Change-Id: I7b23eccdc944d2cb068f584b01b52835aca938e9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84004


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarGarvin Hicking <gh@faktor-e.de>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarGarvin Hicking <gh@faktor-e.de>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
parent c47c83f3
Branches
Tags
No related merge requests found
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