[!!!][TASK] Remove database field "t3ver_id" 59/60459/3
authorBenni Mack <benni@typo3.org>
Fri, 12 Apr 2019 19:12:22 +0000 (21:12 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 15 May 2019 19:15:17 +0000 (21:15 +0200)
The database field "t3ver_id" which is managed by TYPO3 to store the
number of the version for a specific version is not in use anymore,
as this was related to the non-workspace managed versioning concept.

This linear versioning concept was removed, so the database field is
not needed anymore.

It is recommended for all extensions with TYPO3 v10.0+ compat only
to remove this field.

Resolves: #88143
Releases: master
Change-Id: I283e8e2ba2d755dcc8b2054e2439f9fef5462511
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60459
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Achim Fritz <af@achimfritz.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
18 files changed:
typo3/sysext/backend/Classes/Form/FormDataProvider/InlineOverrideChildTca.php
typo3/sysext/backend/Classes/Tree/Repository/PageTreeRepository.php
typo3/sysext/backend/Classes/Tree/View/BrowseTreeView.php
typo3/sysext/backend/Classes/Tree/View/PageTreeView.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/Database/Schema/DefaultTcaSchema.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-88143-Version-relatedDatabaseFieldT3ver_idRemoved.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Database/Schema/DefaultTcaSchemaSqliteTest.php
typo3/sysext/core/Tests/Unit/Database/Schema/DefaultTcaSchemaTest.php
typo3/sysext/core/Tests/Unit/Imaging/IconFactoryTest.php
typo3/sysext/frontend/Tests/Functional/Fixtures/pages-title-tag.xml
typo3/sysext/frontend/Tests/Functional/Fixtures/pages.xml
typo3/sysext/lowlevel/Classes/Integrity/DatabaseIntegrityCheck.php
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
typo3/sysext/workspaces/Classes/Service/GridDataService.php

index a4c4bb8..8bea3c7 100644 (file)
@@ -35,7 +35,6 @@ class InlineOverrideChildTca implements FormDataProviderInterface
         'uid',
         'pid',
         't3ver_oid',
-        't3ver_id',
         't3ver_wsid',
         't3ver_state',
         't3ver_stage',
index 5875cc1..ad4f931 100644 (file)
@@ -55,7 +55,6 @@ class PageTreeRepository
         'extendToSubpages',
         'content_from_pid',
         't3ver_oid',
-        't3ver_id',
         't3ver_wsid',
         't3ver_state',
         't3ver_stage',
index 6b3b2a1..90fcfc4 100644 (file)
@@ -37,7 +37,6 @@ class BrowseTreeView extends AbstractTreeView
         'nav_title',
         'mount_pid',
         'php_tree_stop',
-        't3ver_id',
         't3ver_state',
         'hidden',
         'starttime',
index 0c849be..de7842c 100644 (file)
@@ -33,7 +33,6 @@ class PageTreeView extends AbstractTreeView
         'nav_title',
         'mount_pid',
         'php_tree_stop',
-        't3ver_id',
         't3ver_state',
         'hidden',
         'starttime',
index 2027a6e..bcd9d82 100644 (file)
@@ -1208,9 +1208,6 @@ class BackendUtility
             $out = htmlspecialchars($parts[0]);
             return $includeAttrib ? 'title="' . $out . '"' : $out;
         }
-        if ($row['pid'] < 0) {
-            $parts[] = 'v#1.' . $row['t3ver_id'];
-        }
         switch (VersionState::cast($row['t3ver_state'])) {
             case new VersionState(VersionState::NEW_PLACEHOLDER):
                 $parts[] = 'PLH WSID#' . $row['t3ver_wsid'];
@@ -1324,9 +1321,6 @@ class BackendUtility
             $ctrl = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
             // Uid is added
             $out .= 'id=' . $row['uid'];
-            if (static::isTableWorkspaceEnabled($table) && $row['pid'] < 0) {
-                $out .= ' - v#1.' . $row['t3ver_id'];
-            }
             if (static::isTableWorkspaceEnabled($table)) {
                 switch (VersionState::cast($row['t3ver_state'])) {
                     case new VersionState(VersionState::NEW_PLACEHOLDER):
@@ -2101,7 +2095,6 @@ class BackendUtility
             }
         }
         if (static::isTableWorkspaceEnabled($table)) {
-            $fields[] = $prefix . 't3ver_id';
             $fields[] = $prefix . 't3ver_state';
             $fields[] = $prefix . 't3ver_wsid';
             $fields[] = $prefix . 't3ver_count';
@@ -3405,7 +3398,7 @@ class BackendUtility
      *
      *******************************************/
     /**
-     * Select all versions of a record, ordered by version id (DESC)
+     * Select all versions of a record, ordered by latest created version (uid DESC)
      *
      * @param string $table Table name to select from
      * @param int $uid Record uid for which to find versions.
@@ -3454,7 +3447,7 @@ class BackendUtility
                     $queryBuilder->expr()->neq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)),
                     $queryBuilder->expr()->eq('t3ver_oid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT))
                 )
-                ->orderBy('t3ver_id', 'DESC');
+                ->orderBy('uid', 'DESC');
 
             if (!$includeDeletedRecords) {
                 $queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
index 7c0a8a0..6915185 100644 (file)
@@ -3804,7 +3804,6 @@ class PageLayoutView implements LoggerAwareInterface
                     }
                     if (ExtensionManagementUtility::isLoaded('workspaces')
                         && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
-                        $fieldListArr[] = 't3ver_id';
                         $fieldListArr[] = 't3ver_state';
                         $fieldListArr[] = 't3ver_wsid';
                     }
index 8339a4d..d0d844a 100644 (file)
@@ -549,7 +549,7 @@ class BackendUtilityTest extends UnitTestCase
                         'versioningWS' => true
                     ]
                 ],
-                'expectedFields' => 'uid,t3ver_id,t3ver_state,t3ver_wsid,t3ver_count'
+                'expectedFields' => 'uid,t3ver_state,t3ver_wsid,t3ver_count'
             ],
             'selicon_field set' => [
                 'table' => 'test_table',
index 1369fb2..a914f20 100644 (file)
@@ -1119,7 +1119,6 @@ class DataHandler implements LoggerAwareInterface
                             // For the actual new offline version, set versioning values to point to placeholder:
                             $fieldArray['pid'] = -1;
                             $fieldArray['t3ver_oid'] = $this->substNEWwithIDs[$id];
-                            $fieldArray['t3ver_id'] = 1;
                             // Setting placeholder state value for version (so it can know it is currently a new version...)
                             $fieldArray['t3ver_state'] = (string)new VersionState(VersionState::NEW_PLACEHOLDER_VERSION);
                             $fieldArray['t3ver_wsid'] = $this->BE_USER->workspace;
@@ -1384,7 +1383,6 @@ class DataHandler implements LoggerAwareInterface
                     }
                     break;
                 case 't3ver_oid':
-                case 't3ver_id':
                 case 't3ver_wsid':
                 case 't3ver_state':
                 case 't3ver_count':
@@ -3142,7 +3140,7 @@ class DataHandler implements LoggerAwareInterface
         }
 
         $data = [];
-        $nonFields = array_unique(GeneralUtility::trimExplode(',', 'uid,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,t3ver_oid,t3ver_wsid,t3ver_id,t3ver_state,t3ver_count,t3ver_stage,t3ver_tstamp,' . $excludeFields, true));
+        $nonFields = array_unique(GeneralUtility::trimExplode(',', 'uid,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_count,t3ver_stage,t3ver_tstamp,' . $excludeFields, true));
         BackendUtility::workspaceOL($table, $row, -99, false);
         $row = BackendUtility::purgeComputedPropertiesFromRecord($row);
 
@@ -3461,7 +3459,7 @@ class DataHandler implements LoggerAwareInterface
         }
 
         // Set up fields which should not be processed. They are still written - just passed through no-questions-asked!
-        $nonFields = ['uid', 'pid', 't3ver_id', 't3ver_oid', 't3ver_wsid', 't3ver_state', 't3ver_count', 't3ver_stage', 't3ver_tstamp', 'perms_userid', 'perms_groupid', 'perms_user', 'perms_group', 'perms_everybody'];
+        $nonFields = ['uid', 'pid', 't3ver_oid', 't3ver_wsid', 't3ver_state', 't3ver_count', 't3ver_stage', 't3ver_tstamp', 'perms_userid', 'perms_groupid', 'perms_user', 'perms_group', 'perms_everybody'];
 
         // Merge in override array.
         $row = array_merge($row, $overrideArray);
@@ -5175,26 +5173,8 @@ class DataHandler implements LoggerAwareInterface
             return null;
         }
 
-        // Look for next version number:
-        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
-        $this->addDeleteRestriction($queryBuilder->getRestrictions()->removeAll());
-        $highestVerNumber = $queryBuilder
-            ->select('t3ver_id')
-            ->from($table)
-            ->where($queryBuilder->expr()->orX(
-                $queryBuilder->expr()->andX(
-                    $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
-                    $queryBuilder->expr()->eq('t3ver_oid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT))
-                ),
-                $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT))
-            ))
-            ->orderBy('t3ver_id', 'DESC')
-            ->setMaxResults(1)
-            ->execute()
-            ->fetchColumn();
         // Set up the values to override when making a raw-copy:
         $overrideArray = [
-            't3ver_id' => $highestVerNumber + 1,
             't3ver_oid' => $id,
             't3ver_wsid' => $this->BE_USER->workspace,
             't3ver_state' => (string)($delete ? new VersionState(VersionState::DELETE_PLACEHOLDER) : new VersionState(VersionState::DEFAULT_STATE)),
index a78c7b0..38e6452 100644 (file)
@@ -384,22 +384,6 @@ class DefaultTcaSchema
                 );
             }
 
-            // workspaces t3ver_id column
-            if (!empty($tableDefinition['ctrl']['versioningWS'])
-                && (bool)$tableDefinition['ctrl']['versioningWS'] === true
-                && !$this->isColumnDefinedForTable($tables, $tableName, 't3ver_id')
-            ) {
-                $tables[$tablePosition]->addColumn(
-                    $this->quote('t3ver_id'),
-                    'integer',
-                    [
-                        'default' => 0,
-                        'notnull' => true,
-                        'unsigned' => true,
-                    ]
-                );
-            }
-
             // workspaces t3ver_wsid column
             if (!empty($tableDefinition['ctrl']['versioningWS'])
                 && (bool)$tableDefinition['ctrl']['versioningWS'] === true
@@ -581,7 +565,6 @@ class DefaultTcaSchema
             $prioritizedFieldNames[] = 't3ver_oid';
             $prioritizedFieldNames[] = 't3ver_state';
             $prioritizedFieldNames[] = 't3ver_stage';
-            $prioritizedFieldNames[] = 't3ver_id';
             $prioritizedFieldNames[] = 't3ver_move_id';
             $prioritizedFieldNames[] = 't3ver_count';
             $prioritizedFieldNames[] = 't3ver_tstamp';
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-88143-Version-relatedDatabaseFieldT3ver_idRemoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-88143-Version-relatedDatabaseFieldT3ver_idRemoved.rst
new file mode 100644 (file)
index 0000000..fa93d53
--- /dev/null
@@ -0,0 +1,43 @@
+.. include:: ../../Includes.txt
+
+====================================================================
+Breaking: #88143 - Version-related database field "t3ver_id" removed
+====================================================================
+
+See :issue:`88143`
+
+Description
+===========
+
+The database field for all workspace-enabled database tables `t3ver_id` is removed. It previously
+contained an incrementing numeric value when using incrementing versioning - the versioning concept
+which was in place before Workspaces were introduced in TYPO3 v4.0.
+
+Since the legacy versioning was removed in TYPO3 v9, the field is removed and not automatically
+created for new installations anymore.
+
+
+Impact
+======
+
+Creating SQL statements in custom extensions explicitly selecting this field will result in SQL
+errors.
+
+In addition, when upgrading TYPO3 to v10.0. this field will be removed by the Database Analyzer
+Tool in the Install Tool for all TYPO3 core database tables and extensions using the automatic
+creation of database fields.
+
+
+Affected Installations
+======================
+
+All installations with custom extensions explicitly requesting this field.
+
+
+Migration
+=========
+
+Search in any extension in `typo3conf/ext` for `t3ver_id` to see any usages, and remove the field
+from any queries, database definitions in `ext_tables.sql` files.
+
+.. index:: Database, NotScanned, ext:workspaces
\ No newline at end of file
index f7f0a7d..72c1b92 100644 (file)
@@ -671,27 +671,6 @@ class DefaultTcaSchemaSqliteTest extends UnitTestCase
     /**
      * @test
      */
-    public function enrichAddsT3verId()
-    {
-        $GLOBALS['TCA']['aTable']['ctrl'] = [
-            'versioningWS' => true,
-        ];
-        $result = $this->subject->enrich([]);
-        $expectedColumn = new Column(
-            '`t3ver_id`',
-            Type::getType('integer'),
-            [
-                'default' => 0,
-                'notnull' => true,
-                'unsigned' => true,
-            ]
-        );
-        $this->assertEquals($expectedColumn, $result[0]->getColumn('t3ver_id'));
-    }
-
-    /**
-     * @test
-     */
     public function enrichAddsT3verWsid()
     {
         $GLOBALS['TCA']['aTable']['ctrl'] = [
index 395a36e..8d527bc 100644 (file)
@@ -672,27 +672,6 @@ class DefaultTcaSchemaTest extends UnitTestCase
     /**
      * @test
      */
-    public function enrichAddsT3verId()
-    {
-        $GLOBALS['TCA']['aTable']['ctrl'] = [
-            'versioningWS' => true,
-        ];
-        $result = $this->subject->enrich([]);
-        $expectedColumn = new Column(
-            '`t3ver_id`',
-            Type::getType('integer'),
-            [
-                'default' => 0,
-                'notnull' => true,
-                'unsigned' => true,
-            ]
-        );
-        $this->assertEquals($expectedColumn, $result[0]->getColumn('t3ver_id'));
-    }
-
-    /**
-     * @test
-     */
     public function enrichAddsT3verWsid()
     {
         $GLOBALS['TCA']['aTable']['ctrl'] = [
index aeba2ea..f4f4511 100644 (file)
@@ -75,7 +75,6 @@ class IconFactoryTest extends UnitTestCase
         'endtime' => '0',
         'fe_group' => '',
         'CType' => 'text',
-        't3ver_id' => '0',
         't3ver_state' => '0',
         't3ver_wsid' => '0',
         'sys_language_uid' => '0',
index e19e69c..f7847bb 100644 (file)
@@ -76,7 +76,6 @@
         <title>Workspace Root</title>
         <deleted>0</deleted>
         <t3ver_oid>0</t3ver_oid>
-        <t3ver_id>0</t3ver_id>
         <t3ver_wsid>987654321</t3ver_wsid>
         <t3ver_state>1</t3ver_state>
         <perms_everybody>15</perms_everybody>
@@ -87,7 +86,6 @@
         <title>Workspace Root</title>
         <deleted>0</deleted>
         <t3ver_oid>11</t3ver_oid>
-        <t3ver_id>1</t3ver_id>
         <t3ver_wsid>987654321</t3ver_wsid>
         <t3ver_state>-1</t3ver_state>
         <perms_everybody>15</perms_everybody>
index 687fe77..d709aa3 100644 (file)
@@ -77,7 +77,6 @@
         <title>Workspace Root</title>
         <deleted>0</deleted>
         <t3ver_oid>0</t3ver_oid>
-        <t3ver_id>0</t3ver_id>
         <t3ver_wsid>987654321</t3ver_wsid>
         <t3ver_state>1</t3ver_state>
         <perms_everybody>15</perms_everybody>
@@ -88,7 +87,6 @@
         <title>Workspace Root</title>
         <deleted>0</deleted>
         <t3ver_oid>11</t3ver_oid>
-        <t3ver_id>1</t3ver_id>
         <t3ver_wsid>987654321</t3ver_wsid>
         <t3ver_state>-1</t3ver_state>
         <perms_everybody>15</perms_everybody>
index d229a97..07d92ac 100644 (file)
@@ -128,7 +128,7 @@ class DatabaseIntegrityCheck
             ->from('pages')
             ->orderBy('sorting');
         if ($versions) {
-            $queryBuilder->addSelect('t3ver_wsid', 't3ver_id', 't3ver_count');
+            $queryBuilder->addSelect('t3ver_wsid', 't3ver_count');
             $queryBuilder->where(
                 $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)),
                 $queryBuilder->expr()->eq('t3ver_oid', $queryBuilder->createNamedParameter($theID, \PDO::PARAM_INT))
index 87e9e2f..89f4e86 100644 (file)
@@ -998,7 +998,6 @@ class DatabaseRecordList
             }
         }
         if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
-            $selectFields[] = 't3ver_id';
             $selectFields[] = 't3ver_state';
             $selectFields[] = 't3ver_wsid';
         }
@@ -3804,7 +3803,6 @@ class DatabaseRecordList
                     if (ExtensionManagementUtility::isLoaded(
                         'workspaces'
                         ) && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
-                        $fieldListArr[] = 't3ver_id';
                         $fieldListArr[] = 't3ver_state';
                         $fieldListArr[] = 't3ver_wsid';
                     }
index 91cc85c..5cfafdb 100644 (file)
@@ -163,7 +163,6 @@ class GridDataService implements LoggerAwareInterface
                     $versionArray['table'] = $table;
                     $versionArray['id'] = $table . ':' . $record['uid'];
                     $versionArray['uid'] = $record['uid'];
-                    $versionArray['workspace'] = $versionRecord['t3ver_id'];
                     $versionArray = array_merge($versionArray, $defaultGridColumns);
                     $versionArray['label_Workspace'] = htmlspecialchars(BackendUtility::getRecordTitle($table, $versionRecord));
                     $versionArray['label_Live'] = htmlspecialchars(BackendUtility::getRecordTitle($table, $origRecord));