Commit 139d92bd authored by Benni Mack's avatar Benni Mack Committed by Christian Kuhn
Browse files

[!!!][TASK] Remove fixVersioningPid in FE and BE

The methods `PageRepository->fixVersioningPid()` and
`BackendUtility::fixVersioningPid` are removed,
because they are not needed anymore since TYPO3 v11.0
with the removal of various VersionState (t3ver_state).

Resolves: #96120
Related: #92598
Releases: master
Change-Id: I029169563e094b42a2e8a1a52d0a6533984436d9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72341

Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent c08c298b
Pipeline #19968 passed with stages
in 16 minutes and 3 seconds
......@@ -165,7 +165,7 @@ class FormDataCompiler
// Holds the "neighbor" row if incoming vanillaUid is negative and record creation is relative to a row of the same table.
'neighborRow' => null,
// For "new" this is the fully initialized row with defaults
// The database row. For "edit" fixVersioningPid() was applied already.
// The database row. For "edit" workspaceOL() was applied already.
// @todo: rename to valueStructure or handledData or similar
'databaseRow' => [],
// The "effective" page uid we're working on. This is the uid of a page if a page is edited, or the uid
......
......@@ -3293,70 +3293,6 @@ class BackendUtility
return null;
}
/**
* Find page-tree PID for versionized record
* Used whenever you are tracking something back, like making the root line.
* Will only translate if the workspace of the input record matches that of the current user (unless flag set)
* Principle; Record offline! => Find online?
*
* If the record had its pid corrected to the online versions pid,
* then "_ORIG_pid" is set for moved records to the PID of the moved location.
*
* @param string $table Table name
* @param array $rr Record array passed by reference. As minimum, "pid" and "uid" fields must exist! "t3ver_oid", "t3ver_state" and "t3ver_wsid" is nice and will save you a DB query.
* @param bool $ignoreWorkspaceMatch Ignore workspace match
* @see PageRepository::fixVersioningPid()
* @internal should only be used from within TYPO3 Core
* @deprecated will be removed in TYPO3 v12, use workspaceOL() or getRecordWSOL() directly to achieve the same result.
*/
public static function fixVersioningPid($table, &$rr, $ignoreWorkspaceMatch = false)
{
trigger_error('BackendUtility::fixVersioningPid() will be removed in TYPO3 v12, use BackendUtility::workspaceOL() or BackendUtility::getRecordWSOL() directly.', E_USER_DEPRECATED);
if (!ExtensionManagementUtility::isLoaded('workspaces')) {
return;
}
if (!static::isTableWorkspaceEnabled($table)) {
return;
}
// Check that the input record is an offline version from a table that supports versioning
if (!is_array($rr)) {
return;
}
$incomingPid = $rr['pid'] ?? null;
// Check values for t3ver_oid and t3ver_wsid:
if (isset($rr['t3ver_oid']) && isset($rr['t3ver_wsid']) && isset($rr['t3ver_state'])) {
// If "t3ver_oid" is already a field, just set this:
$oid = $rr['t3ver_oid'];
$workspaceId = (int)$rr['t3ver_wsid'];
$versionState = (int)$rr['t3ver_state'];
} else {
$oid = 0;
$workspaceId = 0;
$versionState = 0;
// Otherwise we have to expect "uid" to be in the record and look up based on this:
$newPidRec = self::getRecord($table, $rr['uid'], 'pid,t3ver_oid,t3ver_wsid,t3ver_state');
if (is_array($newPidRec)) {
$incomingPid = $newPidRec['pid'];
$oid = $newPidRec['t3ver_oid'];
$workspaceId = $newPidRec['t3ver_wsid'];
$versionState = $newPidRec['t3ver_state'];
}
}
if ($oid && ($ignoreWorkspaceMatch || (static::getBackendUserAuthentication() instanceof BackendUserAuthentication && $workspaceId === (int)static::getBackendUserAuthentication()->workspace))) {
// Use moved PID in case of move pointer
if ($versionState === VersionState::MOVE_POINTER) {
if ($incomingPid !== null) {
$movedPageIdInWorkspace = $incomingPid;
} else {
$versionedMovePointer = self::getRecord($table, $rr['uid'], 'pid');
$movedPageIdInWorkspace = $versionedMovePointer['pid'];
}
$rr['_ORIG_pid'] = $incomingPid;
$rr['pid'] = $movedPageIdInWorkspace;
}
}
}
/**
* Workspace Preview Overlay.
*
......@@ -3373,7 +3309,6 @@ class BackendUtility
* @param array $row Record by reference. At least "uid", "pid", "t3ver_oid" and "t3ver_state" must be set. Keys not prefixed with '_' are used as field names in SQL.
* @param int $wsid Workspace ID, if not specified will use static::getBackendUserAuthentication()->workspace
* @param bool $unsetMovePointers If TRUE the function does not return a "pointer" row for moved records in a workspace
* @see fixVersioningPid()
*/
public static function workspaceOL($table, &$row, $wsid = -99, $unsetMovePointers = false)
{
......
......@@ -26,26 +26,6 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
*/
class BackendUtilityTest extends UnitTestCase
{
/**
* @test
*/
public function fixVersioningPidDoesNotChangeValuesForNoBeUserAvailable(): void
{
$GLOBALS['BE_USER'] = null;
$tableName = 'table_a';
$GLOBALS['TCA'][$tableName]['ctrl']['versioningWS'] = 'not_empty';
$rr = [
'pid' => -1,
't3ver_oid' => 7,
't3ver_wsid' => 42,
't3ver_state' => 0,
];
$reference = $rr;
BackendUtility::fixVersioningPid($tableName, $rr);
self::assertSame($reference, $rr);
}
/**
* @test
*/
......
......@@ -1475,82 +1475,6 @@ class PageRepository implements LoggerAwareInterface
*
**********************/
/**
* Finding online PID for offline version record
*
* ONLY active when backend user is previewing records. MUST NEVER affect a site
* served which is not previewed by backend users!!!
*
* What happens in this method:
* If a record was moved in a workspace, the records' PID might be different. This is only reason
* nowadays why this method exists.
*
* This is checked:
* 1. If the record has a "online pendant" (t3ver_oid > 0), it overrides the "pid" with the one from the online version.
* 2. If a record is a live version, check if there is a moved version in this workspace, and override the LIVE version with the new moved "pid" value.
*
* Used whenever you are tracking something back, like making the root line.
*
* Principle; Record offline! => Find online?
*
* @param string $table Table name
* @param array $rr Record array passed by reference. As minimum, "pid" and "uid" fields must exist! Having "t3ver_state" and "t3ver_wsid" is nice and will save you a DB query.
* @see BackendUtility::fixVersioningPid()
* @see versionOL()
* @deprecated will be removed in TYPO3 v12, use versionOL() directly to achieve the same result.
*/
public function fixVersioningPid($table, &$rr)
{
trigger_error('PageRepository->fixVersioningPid() will be removed in TYPO3 v12, use PageRepository->versionOL() instead.', E_USER_DEPRECATED);
if ($this->versioningWorkspaceId <= 0) {
return;
}
if (!is_array($rr)) {
return;
}
if (!$this->hasTableWorkspaceSupport($table)) {
return;
}
$uid = (int)$rr['uid'];
$workspaceId = 0;
$versionState = null;
// Check values for t3ver_state and t3ver_wsid
if (isset($rr['t3ver_wsid']) && isset($rr['t3ver_state'])) {
// If "t3ver_state" is already a field, just set the needed values
$workspaceId = (int)$rr['t3ver_wsid'];
$versionState = (int)$rr['t3ver_state'];
} elseif ($uid > 0) {
// Otherwise we have to expect "uid" to be in the record and look up based
// on this:
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$newPidRec = $queryBuilder->select('t3ver_wsid', 't3ver_state')
->from($table)
->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)))
->execute()
->fetchAssociative();
if (is_array($newPidRec)) {
$workspaceId = (int)$newPidRec['t3ver_wsid'];
$versionState = (int)$newPidRec['t3ver_state'];
}
}
// Workspace does not match, so this is skipped
if ($workspaceId !== (int)$this->versioningWorkspaceId) {
return;
}
// Changing PID in case there is a move pointer
// This happens if the $uid is still a live version but the overlay happened (via t3ver_oid) and the t3ver_state was
// Changed to MOVE_POINTER. This logic happens in versionOL(), where the "pid" of the live version is kept.
if ($versionState === VersionState::MOVE_POINTER && $movedPageId = $this->getMovedPidOfVersionedRecord($table, $uid)) {
$rr['_ORIG_pid'] = $rr['pid'];
$rr['pid'] = $movedPageId;
}
}
/**
* Versioning Preview Overlay
*
......@@ -1568,7 +1492,6 @@ class PageRepository implements LoggerAwareInterface
* @param array $row Record array passed by reference. As minimum, the "uid", "pid" and "t3ver_state" fields must exist! The record MAY be set to FALSE in which case the calling function should act as if the record is forbidden to access!
* @param bool $unsetMovePointers If set, the $row is cleared in case it is a move-pointer. This is only for preview of moved records (to remove the record from the original location so it appears only in the new location)
* @param bool $bypassEnableFieldsCheck Unless this option is TRUE, the $row is unset if enablefields for BOTH the version AND the online record deselects it. This is because when versionOL() is called it is assumed that the online record is already selected with no regards to it's enablefields. However, after looking for a new version the online record enablefields must ALSO be evaluated of course. This is done all by this function!
* @see fixVersioningPid()
* @see BackendUtility::workspaceOL()
*/
public function versionOL($table, &$row, $unsetMovePointers = false, $bypassEnableFieldsCheck = false)
......
......@@ -35,11 +35,11 @@ The following PHP class aliases that have previously been marked as deprecated f
The following PHP class methods that have previously been marked as deprecated for v11 and were now removed:
- :php:`\Full\Class\Name->methodName`
- :php:`\TYPO3\CMS\Core\Domain\Repository\PageRepository->fixVersioningPid()`
The following PHP static class methods that have previously been marked as deprecated for v11 and were now removed:
- :php:`\Full\Class\Name::methodName`
- :php:`\TYPO3\CMS\Backend\Utility\BackendUtility::fixVersioningPid()`
The following methods changed signature according to previous deprecations in v11 at the end of the argument list:
......
......@@ -4505,6 +4505,7 @@ return [
'maximumNumberOfArguments' => 2,
'restFiles' => [
'Deprecation-92598-Workspace-relatedMethodsFixVersioningPid.rst',
'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
],
],
'TYPO3\CMS\Core\Authentication\AbstractUserAuthentication->checkLogFailures' => [
......
......@@ -1056,6 +1056,7 @@ return [
'maximumNumberOfArguments' => 3,
'restFiles' => [
'Deprecation-92598-Workspace-relatedMethodsFixVersioningPid.rst',
'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
],
],
'TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList' => [
......
Markdown is supported
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