[TASK] Move RecordHistory into DataHandling namespace 73/57773/3
authorBenni Mack <benni@typo3.org>
Thu, 2 Aug 2018 10:44:39 +0000 (12:44 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 2 Aug 2018 17:21:22 +0000 (19:21 +0200)
The newly created (internal) RecordHistory class is
moved to the DataHandling namespace as it is related
to all other logic (e.g. DataHandler).

Resolves: #85728
Releases: master
Change-Id: Ib3cf60541e638586f246d64542d0e19bef7f62e8
Reviewed-on: https://review.typo3.org/57773
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Controller/ContentElement/ElementHistoryController.php
typo3/sysext/backend/Classes/History/RecordHistory.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/DataHandling/History/RecordHistoryStore.php [new file with mode: 0644]
typo3/sysext/core/Classes/History/RecordHistoryStore.php [deleted file]
typo3/sysext/core/Migrations/Code/ClassAliasMap.php
typo3/sysext/install/Classes/Updates/SeparateSysHistoryFromSysLogUpdate.php
typo3/sysext/recycler/Classes/Controller/DeletedRecordsController.php

index ed119e1..b96ee1f 100644 (file)
@@ -20,7 +20,7 @@ use TYPO3\CMS\Backend\History\RecordHistory;
 use TYPO3\CMS\Backend\Template\Components\ButtonBar;
 use TYPO3\CMS\Backend\Template\ModuleTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
-use TYPO3\CMS\Core\History\RecordHistoryStore;
+use TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
index a5c50c1..7b94a34 100644 (file)
@@ -18,7 +18,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
-use TYPO3\CMS\Core\History\RecordHistoryStore;
+use TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
index 5e36bff..7245df9 100644 (file)
@@ -43,8 +43,8 @@ use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\QueryRestrictionContainerInterface;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\Database\RelationHandler;
+use TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore;
 use TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor;
-use TYPO3\CMS\Core\History\RecordHistoryStore;
 use TYPO3\CMS\Core\Html\RteHtmlParser;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
diff --git a/typo3/sysext/core/Classes/DataHandling/History/RecordHistoryStore.php b/typo3/sysext/core/Classes/DataHandling/History/RecordHistoryStore.php
new file mode 100644 (file)
index 0000000..8f5fe71
--- /dev/null
@@ -0,0 +1,199 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Core\DataHandling\History;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Database\Connection;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Used to save any history to a record
+ *
+ * @internal should only be used by the TYPO3 Core
+ */
+class RecordHistoryStore
+{
+    public const ACTION_ADD = 1;
+    public const ACTION_MODIFY = 2;
+    public const ACTION_MOVE = 3;
+    public const ACTION_DELETE = 4;
+    public const ACTION_UNDELETE = 5;
+
+    public const USER_BACKEND = 'BE';
+    public const USER_FRONTEND = 'FE';
+    public const USER_ANONYMOUS = '';
+
+    /**
+     * @var int|null
+     */
+    protected $userId;
+
+    /**
+     * @var string
+     */
+    protected $userType;
+
+    /**
+     * @var int|null
+     */
+    protected $originalUserId;
+
+    /**
+     * @var int|null
+     */
+    protected $tstamp;
+
+    /**
+     * @var int
+     */
+    protected $workspaceId;
+
+    /**
+     * @param int|null $userId
+     * @param string $userType
+     * @param int $originalUserId
+     * @param int $tstamp
+     * @param int $workspaceId
+     */
+    public function __construct(string $userType = self::USER_BACKEND, int $userId = null, int $originalUserId = null, int $tstamp = null, int $workspaceId = 0)
+    {
+        $this->userId = $userId;
+        $this->userType = $userType;
+        $this->originalUserId = $originalUserId;
+        $this->tstamp = $tstamp ?: $GLOBALS['EXEC_TIME'];
+        $this->workspaceId = $workspaceId;
+    }
+
+    /**
+     * @param string $table
+     * @param int $uid
+     * @param array $payload
+     * @return string
+     */
+    public function addRecord(string $table, int $uid, array $payload): string
+    {
+        $data = [
+            'actiontype' => self::ACTION_ADD,
+            'usertype' => $this->userType,
+            'userid' => $this->userId,
+            'originaluserid' => $this->originalUserId,
+            'tablename' => $table,
+            'recuid' => $uid,
+            'tstamp' => $this->tstamp,
+            'history_data' => json_encode($payload),
+            'workspace' => $this->workspaceId,
+        ];
+        $this->getDatabaseConnection()->insert('sys_history', $data);
+        return $this->getDatabaseConnection()->lastInsertId('sys_history');
+    }
+
+    /**
+     * @param string $table
+     * @param int $uid
+     * @param array $payload
+     * @return string
+     */
+    public function modifyRecord(string $table, int $uid, array $payload): string
+    {
+        $data = [
+            'actiontype' => self::ACTION_MODIFY,
+            'usertype' => $this->userType,
+            'userid' => $this->userId,
+            'originaluserid' => $this->originalUserId,
+            'tablename' => $table,
+            'recuid' => $uid,
+            'tstamp' => $this->tstamp,
+            'history_data' => json_encode($payload),
+            'workspace' => $this->workspaceId,
+        ];
+        $this->getDatabaseConnection()->insert('sys_history', $data);
+        return $this->getDatabaseConnection()->lastInsertId('sys_history');
+    }
+
+    /**
+     * @param string $table
+     * @param int $uid
+     * @return string
+     */
+    public function deleteRecord(string $table, int $uid): string
+    {
+        $data = [
+            'actiontype' => self::ACTION_DELETE,
+            'usertype' => $this->userType,
+            'userid' => $this->userId,
+            'originaluserid' => $this->originalUserId,
+            'tablename' => $table,
+            'recuid' => $uid,
+            'tstamp' => $this->tstamp,
+            'workspace' => $this->workspaceId,
+        ];
+        $this->getDatabaseConnection()->insert('sys_history', $data);
+        return $this->getDatabaseConnection()->lastInsertId('sys_history');
+    }
+
+    /**
+     * @param string $table
+     * @param int $uid
+     * @return string
+     */
+    public function undeleteRecord(string $table, int $uid): string
+    {
+        $data = [
+            'actiontype' => self::ACTION_UNDELETE,
+            'usertype' => $this->userType,
+            'userid' => $this->userId,
+            'originaluserid' => $this->originalUserId,
+            'tablename' => $table,
+            'recuid' => $uid,
+            'tstamp' => $this->tstamp,
+            'workspace' => $this->workspaceId,
+        ];
+        $this->getDatabaseConnection()->insert('sys_history', $data);
+        return $this->getDatabaseConnection()->lastInsertId('sys_history');
+    }
+
+    /**
+     * @param string $table
+     * @param int $uid
+     * @param array $payload
+     * @return string
+     */
+    public function moveRecord(string $table, int $uid, array $payload): string
+    {
+        $data = [
+            'actiontype' => self::ACTION_MOVE,
+            'usertype' => $this->userType,
+            'userid' => $this->userId,
+            'originaluserid' => $this->originalUserId,
+            'tablename' => $table,
+            'recuid' => $uid,
+            'tstamp' => $this->tstamp,
+            'history_data' => json_encode($payload),
+            'workspace' => $this->workspaceId,
+        ];
+        $this->getDatabaseConnection()->insert('sys_history', $data);
+        return $this->getDatabaseConnection()->lastInsertId('sys_history');
+    }
+
+    /**
+     * @return Connection
+     */
+    protected function getDatabaseConnection(): Connection
+    {
+        return GeneralUtility::makeInstance(ConnectionPool::class)
+            ->getConnectionForTable('sys_history');
+    }
+}
diff --git a/typo3/sysext/core/Classes/History/RecordHistoryStore.php b/typo3/sysext/core/Classes/History/RecordHistoryStore.php
deleted file mode 100644 (file)
index b47e891..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-<?php
-declare(strict_types = 1);
-namespace TYPO3\CMS\Core\History;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Database\Connection;
-use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
-/**
- * Used to save any history to a record
- *
- * @internal should only be used by the TYPO3 Core
- */
-class RecordHistoryStore
-{
-    const ACTION_ADD = 1;
-    const ACTION_MODIFY = 2;
-    const ACTION_MOVE = 3;
-    const ACTION_DELETE = 4;
-    const ACTION_UNDELETE = 5;
-
-    const USER_BACKEND = 'BE';
-    const USER_FRONTEND = 'FE';
-    const USER_ANONYMOUS = '';
-
-    /**
-     * @var int|null
-     */
-    protected $userId;
-    protected $userType;
-    protected $originalUserId;
-    protected $tstamp;
-    protected $workspaceId;
-
-    /**
-     * @param int|null $userId
-     * @param string $userType
-     * @param int $originalUserId
-     * @param int $tstamp
-     * @param int $workspaceId
-     */
-    public function __construct(string $userType = self::USER_BACKEND, int $userId = null, int $originalUserId = null, int $tstamp = null, int $workspaceId = 0)
-    {
-        $this->userId = $userId;
-        $this->userType = $userType;
-        $this->originalUserId = $originalUserId;
-        $this->tstamp = $tstamp ?: $GLOBALS['EXEC_TIME'];
-        $this->workspaceId = $workspaceId;
-    }
-
-    /**
-     * @param string $table
-     * @param int $uid
-     * @param array $payload
-     * @return string
-     */
-    public function addRecord(string $table, int $uid, array $payload): string
-    {
-        $data = [
-            'actiontype' => self::ACTION_ADD,
-            'usertype' => $this->userType,
-            'userid' => $this->userId,
-            'originaluserid' => $this->originalUserId,
-            'tablename' => $table,
-            'recuid' => $uid,
-            'tstamp' => $this->tstamp,
-            'history_data' => json_encode($payload),
-            'workspace' => $this->workspaceId,
-        ];
-        $this->getDatabaseConnection()->insert('sys_history', $data);
-        return $this->getDatabaseConnection()->lastInsertId('sys_history');
-    }
-
-    /**
-     * @param string $table
-     * @param int $uid
-     * @param array $payload
-     * @return string
-     */
-    public function modifyRecord(string $table, int $uid, array $payload): string
-    {
-        $data = [
-            'actiontype' => self::ACTION_MODIFY,
-            'usertype' => $this->userType,
-            'userid' => $this->userId,
-            'originaluserid' => $this->originalUserId,
-            'tablename' => $table,
-            'recuid' => $uid,
-            'tstamp' => $this->tstamp,
-            'history_data' => json_encode($payload),
-            'workspace' => $this->workspaceId,
-        ];
-        $this->getDatabaseConnection()->insert('sys_history', $data);
-        return $this->getDatabaseConnection()->lastInsertId('sys_history');
-    }
-
-    /**
-     * @param string $table
-     * @param int $uid
-     * @return string
-     */
-    public function deleteRecord(string $table, int $uid): string
-    {
-        $data = [
-            'actiontype' => self::ACTION_DELETE,
-            'usertype' => $this->userType,
-            'userid' => $this->userId,
-            'originaluserid' => $this->originalUserId,
-            'tablename' => $table,
-            'recuid' => $uid,
-            'tstamp' => $this->tstamp,
-            'workspace' => $this->workspaceId,
-        ];
-        $this->getDatabaseConnection()->insert('sys_history', $data);
-        return $this->getDatabaseConnection()->lastInsertId('sys_history');
-    }
-
-    /**
-     * @param string $table
-     * @param int $uid
-     * @return string
-     */
-    public function undeleteRecord(string $table, int $uid): string
-    {
-        $data = [
-            'actiontype' => self::ACTION_UNDELETE,
-            'usertype' => $this->userType,
-            'userid' => $this->userId,
-            'originaluserid' => $this->originalUserId,
-            'tablename' => $table,
-            'recuid' => $uid,
-            'tstamp' => $this->tstamp,
-            'workspace' => $this->workspaceId,
-        ];
-        $this->getDatabaseConnection()->insert('sys_history', $data);
-        return $this->getDatabaseConnection()->lastInsertId('sys_history');
-    }
-
-    /**
-     * @param string $table
-     * @param int $uid
-     * @param array $payload
-     * @return string
-     */
-    public function moveRecord(string $table, int $uid, array $payload): string
-    {
-        $data = [
-            'actiontype' => self::ACTION_MOVE,
-            'usertype' => $this->userType,
-            'userid' => $this->userId,
-            'originaluserid' => $this->originalUserId,
-            'tablename' => $table,
-            'recuid' => $uid,
-            'tstamp' => $this->tstamp,
-            'history_data' => json_encode($payload),
-            'workspace' => $this->workspaceId,
-        ];
-        $this->getDatabaseConnection()->insert('sys_history', $data);
-        return $this->getDatabaseConnection()->lastInsertId('sys_history');
-    }
-
-    /**
-     * @return Connection
-     */
-    protected function getDatabaseConnection(): Connection
-    {
-        return GeneralUtility::makeInstance(ConnectionPool::class)
-            ->getConnectionForTable('sys_history');
-    }
-}
index 92bbf10..f25bf93 100644 (file)
@@ -4,5 +4,6 @@ return [
     'TYPO3\\CMS\\ContextHelp\\Controller\\ContextHelpAjaxController' => \TYPO3\CMS\Backend\Controller\ContextHelpAjaxController::class,
     'TYPO3\\CMS\\Sv\\AbstractAuthenticationService' => \TYPO3\CMS\Core\Authentication\AbstractAuthenticationService::class,
     'TYPO3\\CMS\\Sv\\AuthenticationService' => \TYPO3\CMS\Core\Authentication\AuthenticationService::class,
-    'TYPO3\\CMS\\Core\\Tree\\TableConfiguration\\ExtJsArrayTreeRenderer' => \TYPO3\CMS\Core\Tree\TableConfiguration\ArrayTreeRenderer::class
+    'TYPO3\\CMS\\Core\\Tree\\TableConfiguration\\ExtJsArrayTreeRenderer' => \TYPO3\CMS\Core\Tree\TableConfiguration\ArrayTreeRenderer::class,
+    'TYPO3\\CMS\\Core\\History\\RecordHistory' => \TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore::class
 ];
index d3cc6a9..24f4c3d 100644 (file)
@@ -17,7 +17,7 @@ namespace TYPO3\CMS\Install\Updates;
 
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\History\RecordHistoryStore;
+use TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
index f5ed3b8..dce3920 100644 (file)
@@ -19,7 +19,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
-use TYPO3\CMS\Core\History\RecordHistoryStore;
+use TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;