[TASK] Add possibility to purge workspaces move placeholder 69/45069/2
authorOliver Hader <oliver@typo3.org>
Mon, 30 Nov 2015 17:16:59 +0000 (18:16 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 30 Nov 2015 17:31:24 +0000 (18:31 +0100)
During resolving references in a workspace context overlays and
delete-placeholder are considered and it's possible to define
whether they are kept or substituted. This mechanism is missing
for move-placeholders as well.

Resolves: #71990
Releases: master, 6.2
Change-Id: Id0a5326c968b5ceaca2af4c092f9907a91797823
Reviewed-on: https://review.typo3.org/45069
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/core/Classes/DataHandling/PlainDataResolver.php

index 3fe9736..31d62d9 100644 (file)
@@ -57,6 +57,11 @@ class PlainDataResolver {
        protected $keepDeletePlaceholder = FALSE;
 
        /**
+        * @var bool
+        */
+       protected $keepMovePlaceholder = TRUE;
+
+       /**
         * @var int[]
         */
        protected $resolvedIds;
@@ -100,6 +105,15 @@ class PlainDataResolver {
        }
 
        /**
+        * Sets whether move placeholders shall be kept in case they cannot be substituted.
+        *
+        * @param bool $keepMovePlaceholder
+        */
+       public function setKeepMovePlaceholder($keepMovePlaceholder) {
+               $this->keepMovePlaceholder = (bool)$keepMovePlaceholder;
+       }
+
+       /**
         * @return int[]
         */
        public function get() {
@@ -176,10 +190,13 @@ class PlainDataResolver {
                        foreach ($movePlaceholders as $movePlaceholder) {
                                $liveReferenceId = $movePlaceholder['t3ver_move_id'];
                                $movePlaceholderId = $movePlaceholder['uid'];
-                               // If both, MOVE_PLACEHOLDER and MOVE_POINTER are set
-                               if (isset($ids[$liveReferenceId]) && isset($ids[$movePlaceholderId])) {
+                               // Substitute MOVE_PLACEHOLDER and purge live reference
+                               if (isset($ids[$movePlaceholderId])) {
                                        $ids[$movePlaceholderId] = $liveReferenceId;
                                        unset($ids[$liveReferenceId]);
+                               // Just purge live reference
+                               } elseif (!$this->keepMovePlaceholder) {
+                                       unset($ids[$liveReferenceId]);
                                }
                        }
                        $ids = $this->reindex($ids);