[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:core-ci <typo3@b13.com> Tested-by:
Garvin Hicking <gh@faktor-e.de> Tested-by:
Stefan Bürk <stefan@buerk.tech> Reviewed-by:
Garvin Hicking <gh@faktor-e.de> Reviewed-by:
Stefan Bürk <stefan@buerk.tech>
Showing
- Build/phpstan/phpstan-baseline.neon 0 additions, 40 deletionsBuild/phpstan/phpstan-baseline.neon
- typo3/sysext/core/Classes/Log/LogDataTrait.php 13 additions, 9 deletionstypo3/sysext/core/Classes/Log/LogDataTrait.php
- typo3/sysext/core/Tests/Unit/Log/Fixtures/LogDataTraitTestAccessor.php 40 additions, 0 deletions...core/Tests/Unit/Log/Fixtures/LogDataTraitTestAccessor.php
- typo3/sysext/core/Tests/Unit/Log/LogDataTraitTest.php 248 additions, 0 deletionstypo3/sysext/core/Tests/Unit/Log/LogDataTraitTest.php
Please register or sign in to comment