Commit 7f37960a authored by Benni Mack's avatar Benni Mack Committed by Georg Ringer
Browse files

[TASK] Unify log messages in DataHandler to be PSR-3 compliant

This change adapts DataHandler logs to use
interpolation from PSR-3 instead of %s to identify
variables in log_details properly later-on.

This makes all log messages from DataHandler and Workspaces
PSR-3 compliant.

In addition, all messages do not contain a "!" at the end anymore,
as there is no need to emphasize errors through the log message
itself (that's why there is type "Error" for logging).
Same goes for "." in order to be consistent.

Resolves: #97556
Releases: main
Change-Id: Ia509b6e121be64cf89d111bdc260332d343b164c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74526

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Jochen's avatarJochen <rothjochen@gmail.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Jochen's avatarJochen <rothjochen@gmail.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent 9f3b9eca
......@@ -1122,7 +1122,7 @@ class DataHandlerTest extends UnitTestCase
$dataHandlerMock
->expects(self::once())
->method('log')
->with('pages', 0, 3, 0, 2, 'Deleting all pages starting from the root-page is disabled.', -1, [], 0);
->with('pages', 0, 3, 0, 2, 'Deleting all pages starting from the root-page is disabled', -1, [], 0);
$dataHandlerMock->deletePages(0);
}
......
......@@ -555,9 +555,9 @@ class DataHandlerHook
DatabaseAction::PUBLISH,
0,
SystemLogErrorClassification::USER_ERROR,
'Error: You cannot swap versions for record %s:%d you do not have access to edit!',
'Error: You cannot swap versions for record {table}:{uid} you do not have access to edit',
-1,
[$table, $id]
['table' => $table, 'uid' => $id]
);
return;
}
......@@ -584,9 +584,9 @@ class DataHandlerHook
DatabaseAction::PUBLISH,
0,
SystemLogErrorClassification::SYSTEM_ERROR,
'Error: Either online or swap version for %s:%d->%d could not be selected!',
'Error: Either online or swap version for {table}:{uid}->{offlineUid} could not be selected',
-1,
[$table, $id, $swapWith]
['table' => $table, 'uid' => $id, 'offlineUid' => $swapWith]
);
return;
}
......@@ -598,7 +598,7 @@ class DataHandlerHook
}
$wsAccess = $dataHandler->BE_USER->checkWorkspace($workspaceId);
if (!($workspaceId <= 0 || !($wsAccess['publish_access'] & 1) || $currentStage === StagesService::STAGE_PUBLISH_ID)) {
$dataHandler->log($table, (int)$id, DatabaseAction::PUBLISH, 0, SystemLogErrorClassification::USER_ERROR, 'Records in workspace #{workspace} can only be published when in "Publish" stage.', -1, ['workspace' => $workspaceId]);
$dataHandler->log($table, (int)$id, DatabaseAction::PUBLISH, 0, SystemLogErrorClassification::USER_ERROR, 'Records in workspace #{workspace} can only be published when in "Publish" stage', -1, ['workspace' => $workspaceId]);
return;
}
if (!($dataHandler->doesRecordExist($table, $swapWith, Permission::PAGE_SHOW) && $dataHandler->checkRecordUpdateAccess($table, $swapWith))) {
......@@ -607,7 +607,7 @@ class DataHandlerHook
}
// Check if the swapWith record really IS a version of the original!
if (!(((int)$swapVersion['t3ver_oid'] > 0 && (int)$curVersion['t3ver_oid'] === 0) && (int)$swapVersion['t3ver_oid'] === (int)$id)) {
$dataHandler->log($table, $swapWith, DatabaseAction::PUBLISH, 0, SystemLogErrorClassification::SYSTEM_ERROR, 'In offline record, either t3ver_oid was not set or the t3ver_oid didn\'t match the id of the online version as it must!');
$dataHandler->log($table, $swapWith, DatabaseAction::PUBLISH, 0, SystemLogErrorClassification::SYSTEM_ERROR, 'In offline record, either t3ver_oid was not set or the t3ver_oid didn\'t match the id of the online version as it must');
return;
}
$versionState = new VersionState($swapVersion['t3ver_state']);
......@@ -944,7 +944,7 @@ class DataHandlerHook
}
$wsAccess = $dataHandler->BE_USER->checkWorkspace($workspaceId);
if (!($workspaceId <= 0 || !($wsAccess['publish_access'] & 1) || (int)$newRecordInWorkspace['t3ver_stage'] === StagesService::STAGE_PUBLISH_ID)) {
$dataHandler->log($table, $id, DatabaseAction::PUBLISH, 0, SystemLogErrorClassification::USER_ERROR, 'Records in workspace #{workspace} can only be published when in "Publish" stage.', -1, ['workspace' => $workspaceId]);
$dataHandler->log($table, $id, DatabaseAction::PUBLISH, 0, SystemLogErrorClassification::USER_ERROR, 'Records in workspace #{workspace} can only be published when in "Publish" stage', -1, ['workspace' => $workspaceId]);
return;
}
if (!($dataHandler->doesRecordExist($table, $id, Permission::PAGE_SHOW) && $dataHandler->checkRecordUpdateAccess($table, $id))) {
......
Supports Markdown
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