Commit 1003a0f1 authored by Benni Mack's avatar Benni Mack Committed by Andreas Fernandez
Browse files

[!!!][TASK] Remove database field "t3ver_id"

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: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Achim Fritz's avatarAchim Fritz <af@achimfritz.de>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 8e377804
......@@ -35,7 +35,6 @@ class InlineOverrideChildTca implements FormDataProviderInterface
'uid',
'pid',
't3ver_oid',
't3ver_id',
't3ver_wsid',
't3ver_state',
't3ver_stage',
......
......@@ -55,7 +55,6 @@ class PageTreeRepository
'extendToSubpages',
'content_from_pid',
't3ver_oid',
't3ver_id',
't3ver_wsid',
't3ver_state',
't3ver_stage',
......
......@@ -37,7 +37,6 @@ class BrowseTreeView extends AbstractTreeView
'nav_title',
'mount_pid',
'php_tree_stop',
't3ver_id',
't3ver_state',
'hidden',
'starttime',
......
......@@ -33,7 +33,6 @@ class PageTreeView extends AbstractTreeView
'nav_title',
'mount_pid',
'php_tree_stop',
't3ver_id',
't3ver_state',
'hidden',
'starttime',
......
......@@ -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));
......
......@@ -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';
}
......
......@@ -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',
......
......@@ -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)),
......
......@@ -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';
......
.. 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
......@@ -668,27 +668,6 @@ class DefaultTcaSchemaSqliteTest extends UnitTestCase
$this->assertEquals($expectedColumn, $result[0]->getColumn('t3ver_oid'));
}
/**
* @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
*/
......
......@@ -669,27 +669,6 @@ class DefaultTcaSchemaTest extends UnitTestCase
$this->assertEquals($expectedColumn, $result[0]->getColumn('t3ver_oid'));
}
/**
* @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
*/
......
......@@ -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',
......
......@@ -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>
......
......@@ -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>
......
......@@ -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))
......
......@@ -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';
}
......
......@@ -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));
......
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