[BUGFIX] Set correct workspace ID when updating referenceIndex for files
[Packages/TYPO3.CMS.git] / typo3 / sysext / version / Classes / Hook / DataHandlerHook.php
index fbe3223..9c9fd65 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Version\Hook;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
@@ -948,6 +949,13 @@ class DataHandlerHook {
                                                                                                // For delete + completely delete!
                                                                                                $tcemainObj->deleteEl($table, $swapWith, TRUE, TRUE);
                                                                                        }
+
+                                                                                       //Update reference index for live workspace too:
+                                                                                       /** @var $refIndexObj \TYPO3\CMS\Core\Database\ReferenceIndex */
+                                                                                       $refIndexObj = GeneralUtility::makeInstance(ReferenceIndex::class);
+                                                                                       $refIndexObj->setWorkspaceId(0);
+                                                                                       $refIndexObj->updateRefIndexTable($table, $id);
+                                                                                       $refIndexObj->updateRefIndexTable($table, $swapWith);
                                                                                } else {
                                                                                        $tcemainObj->newlog('During Swapping: SQL errors happened: ' . implode('; ', $sqlErrors), 2);
                                                                                }