[BUGFIX] Clear affected caches on page publishing 08/42308/3
authorBart Dubelaar <bartdubelaar@gmail.com>
Tue, 19 Jun 2012 12:54:45 +0000 (14:54 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 6 Aug 2015 17:28:49 +0000 (19:28 +0200)
When publishing a page, the treelist cache should be cleared.
This is fixed by adding a condition that checks for a swap action in
the existing class that hooks into DataHandler and listens for updates to
pages to update the treelist cache.

Change-Id: I0c01450efe9507dcef9f74af626a9ebf3cdc7d4c
Resolves: #37952
Releases: master, 6.2
Reviewed-on: http://review.typo3.org/42308
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/frontend/Classes/Hooks/TreelistCacheUpdateHooks.php

index 7357feb..aa3ec91 100644 (file)
@@ -85,8 +85,8 @@ class TreelistCacheUpdateHooks {
        }
 
        /**
-        * waits for TCEmain commands and looks for deleted pages, if found further
-        * changes take place to determine whether the cache needs to be updated
+        * Waits for DataHandler commands and looks for deleted pages or swapped pages, if found
+        * further changes take place to determine whether the cache needs to be updated
         *
         * @param string $command The TCE command
         * @param string $table The record's table
@@ -96,13 +96,26 @@ class TreelistCacheUpdateHooks {
         * @return void
         */
        public function processCmdmap_postProcess($command, $table, $recordId, $commandValue, \TYPO3\CMS\Core\DataHandling\DataHandler $tceMain) {
-               if ($table == 'pages' && $command == 'delete') {
-                       $deletedRecord = BackendUtility::getRecord($table, $recordId, '*', '', FALSE);
-                       $affectedPageUid = $deletedRecord['uid'];
-                       $affectedPagePid = $deletedRecord['pid'];
+               $action = (is_array($commandValue) && isset($commandValue['action'])) ? (string)$commandValue['action'] : '';
+               if ($table === 'pages' && ($command === 'delete' || ($command === 'version' && $action === 'swap'))) {
+
+                       $affectedRecord = BackendUtility::getRecord($table, $recordId, '*', '', FALSE);
+                       $affectedPageUid = $affectedRecord['uid'];
+                       $affectedPagePid = $affectedRecord['pid'];
+
                        // Faking the updated fields
-                       $updatedFields = array('deleted' => 1);
-                       $clearCacheActions = $this->determineClearCacheActions('update', $updatedFields);
+                       $updatedFields = array();
+                       if ($command === 'delete') {
+                               $updatedFields['deleted'] = 1;
+                       } else {
+                               // page was published to live (swapped)
+                               $updatedFields['t3ver_wsid'] = 0;
+                       }
+                       $clearCacheActions = $this->determineClearCacheActions(
+                               'update',
+                               $updatedFields
+                       );
+
                        $this->processClearCacheActions($affectedPageUid, $affectedPagePid, $updatedFields, $clearCacheActions);
                }
        }
@@ -294,6 +307,8 @@ class TreelistCacheUpdateHooks {
 
                                        case 'extendToSubpages':
 
+                                       case 't3ver_wsid':
+
                                        case 'php_tree_stop':
                                                // php_tree_stop
                                                $actions['allParents'] = TRUE;