The method arrayToLogString() within GeneralUtility is deprecated in favor of using
own implementations, based on PSR-3.
Still, the one place where this method was in use - ListSysLogCommand -
moved the logic into its own protected method.
Resolves: #85086
Releases: master
Change-Id: If6815a5ea9e459258408458b97b7ee4ad901bd40
Reviewed-on: https://review.typo3.org/57056
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
* @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);
--- /dev/null
+.. 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
'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',
+ ],
+ ],
];
];
if ($showDetails) {
- $result[] = str_replace('; ', LF, GeneralUtility::arrayToLogString($row, [
+ $result[] = $this->arrayToLogString($row, [
'uid',
'userid',
'action',
'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;
+ }
}