diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index adf099c6fa118102efb4286a0ec5c367bc10bb4d..c57aa9fd6d8b80de8ce6a901984c7842a5460fdc 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -4022,9 +4022,11 @@ class GeneralUtility * @param mixed $valueList List of keys which should be listed in the output string. Pass a comma list or an array. An empty list outputs the whole array. * @param int $valueLength Long string values are shortened to this length. Default: 20 * @return string Output string with key names and their value as string + * @deprecated since TYPO3 v9.3, will be removed in TYPO3 v10. */ public static function arrayToLogString(array $arr, $valueList = [], $valueLength = 20) { + trigger_error('Method GeneralUtility::arrayToLogString() will be removed in TYPO3 v10. Use CLI-related methods in your code directly.', E_USER_DEPRECATED); $str = ''; if (!is_array($valueList)) { $valueList = self::trimExplode(',', $valueList, true); diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85086-GeneralUtilityArrayToLogString.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85086-GeneralUtilityArrayToLogString.rst new file mode 100644 index 0000000000000000000000000000000000000000..02394d705b79fc287d992ec07c78e3a13529f2f0 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85086-GeneralUtilityArrayToLogString.rst @@ -0,0 +1,37 @@ +.. include:: ../../Includes.txt + +======================================================== +Deprecation: #85086 - GeneralUtility::arrayToLogString() +======================================================== + +See :issue:`85086` + +Description +=========== + +The method :php:`GeneralUtility::arrayToLogString()`, responsible for formatting an array to a string +ready for logging or output, has been marked as deprecated. + + +Impact +====== + +Calling the method directly will trigger a deprecation warning. + + +Affected Installations +====================== + +Any TYPO3 installation with third-party extensions using this method. + + +Migration +========= + +For logging purposes, switch to PSR-3 compatible logging where a log-writer is taking care of outputting / storing +this information properly. + +For other purposes, like CLI-command output, it is recommended to implement this functionality directly in the +corresponding CLI command. + +.. index:: CLI, PHP-API, FullyScanned, ext:core \ No newline at end of file diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php index 70a65316b1618b5e7dee7dd08b6d627e5729cc7c..580413cb6f7a035437cc732f8b0771858b5740c7 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php @@ -547,32 +547,39 @@ return [ 'Deprecation-83475-AggregateValidatorInformationInClassSchema-2.rst', ], ], - 'TYPO3\CMS\backend\Utility\BackendUtility::getPidForModTSconfig' => [ + 'TYPO3\CMS\Backend\Utility\BackendUtility::getPidForModTSconfig' => [ 'numberOfMandatoryArguments' => 3, 'maximumNumberOfArguments' => 3, 'restFiles' => [ 'Deprecation-84994-BackendUtilitygetPidForModTSconfigDeprecated.rst', ], ], - 'TYPO3\CMS\backend\Utility\BackendUtility::getModTSconfig' => [ + 'TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig' => [ 'numberOfMandatoryArguments' => 2, 'maximumNumberOfArguments' => 2, 'restFiles' => [ 'Deprecation-84993-DeprecateSomeTSconfigRelatedMethods.rst', ], ], - 'TYPO3\CMS\backend\Utility\BackendUtility::unsetMenuItems' => [ + 'TYPO3\CMS\Backend\Utility\BackendUtility::unsetMenuItems' => [ 'numberOfMandatoryArguments' => 3, 'maximumNumberOfArguments' => 3, 'restFiles' => [ 'Deprecation-84993-DeprecateSomeTSconfigRelatedMethods.rst', ], ], - 'TYPO3\CMS\saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled' => [ + 'TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled' => [ 'numberOfMandatoryArguments' => 0, 'maximumNumberOfArguments' => 1, 'restFiles' => [ 'Deprecation-85027-SaltedPasswordsRelatedMethodsAndClasses.rst', ], ], + 'TYPO3\CMS\Core\Utility\GeneralUtility::arrayToLogString' => [ + 'numberOfMandatoryArguments' => 1, + 'maximumNumberOfArguments' => 3, + 'restFiles' => [ + 'Deprecation-85086-GeneralUtilityArrayToLogString.rst', + ], + ], ]; diff --git a/typo3/sysext/lowlevel/Classes/Command/ListSysLogCommand.php b/typo3/sysext/lowlevel/Classes/Command/ListSysLogCommand.php index 94708c98bd06180d269bd885e30a72d14c9720f8..c9db8a3430a1e05e9f1d1c6ac38e743e4cae9434 100644 --- a/typo3/sysext/lowlevel/Classes/Command/ListSysLogCommand.php +++ b/typo3/sysext/lowlevel/Classes/Command/ListSysLogCommand.php @@ -92,7 +92,7 @@ class ListSysLogCommand extends Command ]; if ($showDetails) { - $result[] = str_replace('; ', LF, GeneralUtility::arrayToLogString($row, [ + $result[] = $this->arrayToLogString($row, [ 'uid', 'userid', 'action', @@ -107,10 +107,30 @@ class ListSysLogCommand extends Command 'event_pid', 'NEWid', 'workspace' - ])); + ]); } $content[] = $result; } $io->table($tableHeaders, $content); } + + /** + * Converts a one dimensional array to a one line string which can be used for logging or debugging output + * Example: "loginType: FE; refInfo: Array; HTTP_HOST: www.example.org; REMOTE_ADDR: 192.168.1.5; REMOTE_HOST:; security_level:; showHiddenRecords: 0;" + * Previously found in GeneralUtility::arrayToLogString() + * + * @param array $arr Data array which should be outputted + * @param array $valueList List of keys which should be listed in the output string. + * @return string Output string with key names and their value as string + */ + protected function arrayToLogString(array $arr, array $valueList): string + { + $str = ''; + foreach ($arr as $key => $value) { + if (in_array($key, $valueList, true)) { + $str .= (string)$key . trim(': ' . GeneralUtility::fixed_lgd_cs(str_replace(LF, '|', (string)$value), 20)) . LF; + } + } + return $str; + } }