diff --git a/Classes/Controller/RecyclerAjaxController.php b/Classes/Controller/RecyclerAjaxController.php index 4ff19b3..037f41d 100644 --- a/Classes/Controller/RecyclerAjaxController.php +++ b/Classes/Controller/RecyclerAjaxController.php @@ -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; @@ -160,6 +161,7 @@ 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, @@ -167,7 +169,9 @@ protected function transform(array $deletedRowsArray): array ]; 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'][] = [ @@ -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, @@ -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 { diff --git a/Tests/Functional/Fixtures/Database/be_groups.csv b/Tests/Functional/Fixtures/Database/be_groups.csv index 713d486..99150d7 100644 --- a/Tests/Functional/Fixtures/Database/be_groups.csv +++ b/Tests/Functional/Fixtures/Database/be_groups.csv @@ -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 diff --git a/Tests/Functional/Fixtures/Database/be_users.csv b/Tests/Functional/Fixtures/Database/be_users.csv index 99f58b9..034252e 100644 --- a/Tests/Functional/Fixtures/Database/be_users.csv +++ b/Tests/Functional/Fixtures/Database/be_users.csv @@ -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"