Skip to content

Commit

Permalink
[!!!][TASK] Remove TCA option "cruser_id"
Browse files Browse the repository at this point in the history
TYPO3's TCA definition has a setting called `cruser_id`
which automatically is filled with the current TYPO3's
Backend User ID, if created via DataHandler.

However, this information is also available in the
RecordHistory (since its extraction from sys_log in v9)
and can be queried, when needed, directly from there.

This way, all TCA-based tables, having the setting "cruser_id"
do not need to carry this value anymore, as it is duplicated
in TYPO3's data model.

This change removes the evaluation of "cruser_id",
and removes the filling of this property via DataHandler.

The DB field is also not set anymore automatically.

The Info popup (ElementInformationController) now
shows the information from the RecordHistory information.

Resolves: #98024
Releases: main
Change-Id: I1fe54b0ecfc0ee9b2d1867011dd960e1906fd2d4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75123
Tested-by: core-ci <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
  • Loading branch information
bmack authored and sbuerk committed Jul 26, 2022
1 parent 75ea219 commit c2db949
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions Classes/Controller/RecyclerAjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\History\RecordHistory;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
Expand Down Expand Up @@ -160,14 +161,17 @@ protected function transform(array $deletedRowsArray): array
$groupedRecords = [];
$lang = $this->getLanguageService();

$recordHistory = GeneralUtility::makeInstance(RecordHistory::class);
foreach ($deletedRowsArray as $table => $rows) {
$groupedRecords[$table]['information'] = [
'table' => $table,
'title' => $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']),
];
foreach ($rows as $row) {
$pageTitle = $this->getPageTitle((int)$row['pid']);
$backendUserName = $this->getBackendUserInformation((int)$row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']]);
$ownerInformation = $recordHistory->getCreationInformationForRecord($table, $row);
$ownerUid = (int)(is_array($ownerInformation) && $ownerInformation['actiontype'] === 'BE' ? $ownerInformation['userid'] : 0);
$backendUserName = $this->getBackendUserInformation($ownerUid);
$userIdWhoDeleted = $this->getUserWhoDeleted($table, (int)$row['uid']);

$groupedRecords[$table]['records'][] = [
Expand All @@ -178,7 +182,7 @@ protected function transform(array $deletedRowsArray): array
'crdate' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['crdate']]),
'tstamp' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['tstamp']]),
'owner' => $backendUserName,
'owner_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']],
'owner_uid' => $ownerUid,
'title' => BackendUtility::getRecordTitle($table, $row),
'path' => $this->getRecordPath((int)$row['pid']),
'delete_user_uid' => $userIdWhoDeleted,
Expand Down Expand Up @@ -237,6 +241,7 @@ protected function getBackendUserInformation(int $userId): string

/**
* Get the user uid of the user who deleted the record
* @todo: move this to RecordHistory class
*/
protected function getUserWhoDeleted(string $table, int $uid): int
{
Expand Down
6 changes: 3 additions & 3 deletions Tests/Functional/Fixtures/Database/be_groups.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
be_groups,,,,,,,
,uid,pid,tstamp,title,tables_modify,crdate,cruser_id
,1,0,1452959228,editor-group,pages,1452959228,1
be_groups,,,,,,
,uid,pid,tstamp,title,tables_modify,crdate
,1,0,1452959228,editor-group,pages,1452959228
6 changes: 3 additions & 3 deletions Tests/Functional/Fixtures/Database/be_users.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"be_users"
,"uid","pid","tstamp","username","password","admin","disable","starttime","endtime","options","crdate","cruser_id","workspace_perms","deleted","lastlogin","workspace_id","db_mountpoints","usergroup"
,1,0,1366642540,"admin","$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1",1,0,0,0,0,1366642540,0,1,0,1371033743,0,"",""
,2,0,1452944912,"editor","$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1",0,0,0,0,0,1452944912,1,1,0,1452944915,0,"1","1"
,"uid","pid","tstamp","username","password","admin","disable","starttime","endtime","options","crdate","workspace_perms","deleted","lastlogin","workspace_id","db_mountpoints","usergroup"
,1,0,1366642540,"admin","$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1",1,0,0,0,0,1366642540,1,0,1371033743,0,"",""
,2,0,1452944912,"editor","$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1",0,0,0,0,0,1452944912,1,0,1452944915,0,"1","1"

0 comments on commit c2db949

Please sign in to comment.