/** * Release version from this workspace (and into "Live" workspace but as an offline version). * * @param string $table Table name * @param int $id Record UID * @param bool $flush If set, will completely delete element * @param DataHandler $tcemainObj TCEmain object * @return void */ protected function version_clearWSID($table, $id, $flush = FALSE, DataHandler $tcemainObj) { if ($errorCode = $tcemainObj->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) { $tcemainObj->newlog('Attempt to reset workspace for record failed: ' . $errorCode, 1); return; } if (!$tcemainObj->checkRecordUpdateAccess($table, $id)) { $tcemainObj->newlog('Attempt to reset workspace for record failed because you do not have edit access', 1); return; } $liveRec = BackendUtility::getLiveVersionOfRecord($table, $id, 'uid,t3ver_state'); if (!$liveRec) { return; } // Clear workspace ID: $updateData = array('t3ver_wsid' => 0, 't3ver_tstamp' => $GLOBALS['EXEC_TIME']); $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . (int) $id, $updateData); // Clear workspace ID for live version AND DELETE IT as well because it is a new record! if (VersionState::cast($liveRec['t3ver_state'])->equals(VersionState::NEW_PLACEHOLDER) || VersionState::cast($liveRec['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) { $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . (int) $liveRec['uid'], $updateData); // THIS assumes that the record was placeholder ONLY for ONE record (namely $id) $tcemainObj->deleteEl($table, $liveRec['uid'], TRUE); } // If "deleted" flag is set for the version that got released // it doesn't make sense to keep that "placeholder" anymore and we delete it completly. $wsRec = BackendUtility::getRecord($table, $id); if ($flush || (VersionState::cast($wsRec['t3ver_state'])->equals(VersionState::NEW_PLACEHOLDER) || VersionState::cast($wsRec['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER))) { $tcemainObj->deleteEl($table, $id, TRUE, TRUE); } // Remove the move-placeholder if found for live record. if ((int) $GLOBALS['TCA'][$table]['ctrl']['versioningWS'] >= 2) { if ($plhRec = BackendUtility::getMovePlaceholder($table, $liveRec['uid'], 'uid')) { $tcemainObj->deleteEl($table, $plhRec['uid'], TRUE, TRUE); } } }
/** * Release version from this workspace (and into "Live" workspace but as an offline version). * * @param string $table Table name * @param int $id Record UID * @param bool $flush If set, will completely delete element * @param DataHandler $dataHandler DataHandler object * @return void */ protected function version_clearWSID($table, $id, $flush = false, DataHandler $dataHandler) { if ($errorCode = $dataHandler->BE_USER->workspaceCannotEditOfflineVersion($table, $id)) { $dataHandler->newlog('Attempt to reset workspace for record failed: ' . $errorCode, 1); return; } if (!$dataHandler->checkRecordUpdateAccess($table, $id)) { $dataHandler->newlog('Attempt to reset workspace for record failed because you do not have edit access', 1); return; } $liveRec = BackendUtility::getLiveVersionOfRecord($table, $id, 'uid,t3ver_state'); if (!$liveRec) { return; } // Clear workspace ID: $updateData = ['t3ver_wsid' => 0, 't3ver_tstamp' => $GLOBALS['EXEC_TIME']]; $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table); $connection->update($table, $updateData, ['uid' => (int) $id]); // Clear workspace ID for live version AND DELETE IT as well because it is a new record! if (VersionState::cast($liveRec['t3ver_state'])->equals(VersionState::NEW_PLACEHOLDER) || VersionState::cast($liveRec['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) { $connection->update($table, $updateData, ['uid' => (int) $liveRec['uid']]); // THIS assumes that the record was placeholder ONLY for ONE record (namely $id) $dataHandler->deleteEl($table, $liveRec['uid'], true); } // If "deleted" flag is set for the version that got released // it doesn't make sense to keep that "placeholder" anymore and we delete it completly. $wsRec = BackendUtility::getRecord($table, $id); if ($flush || (VersionState::cast($wsRec['t3ver_state'])->equals(VersionState::NEW_PLACEHOLDER) || VersionState::cast($wsRec['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER))) { $dataHandler->deleteEl($table, $id, true, true); } // Remove the move-placeholder if found for live record. if (BackendUtility::isTableWorkspaceEnabled($table)) { if ($plhRec = BackendUtility::getMovePlaceholder($table, $liveRec['uid'], 'uid')) { $dataHandler->deleteEl($table, $plhRec['uid'], true, true); } } }