[BUGFIX] Pagetree filtering crashes on draft moves 40/13040/8
authorBart Dubelaar <bartdubelaar@gmail.com>
Thu, 20 Sep 2012 20:06:14 +0000 (22:06 +0200)
committerStefan Galinski <stefan.galinski@gmail.com>
Fri, 5 Jul 2013 14:14:04 +0000 (16:14 +0200)
This bugfix fixes the following pagetree issues encountered in
a draft workspace:

1. Records moved in draft could not be found
2. Pagetree would crash if a moved page occurs in the rootline of
a filtered page.
3. Filtering only looked at live page title not the draft title

Change-Id: I49c0082d013303d39c0c259a42f9bb74346ba7c8
Fixes: #39197
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/13040
Reviewed-by: Ingo Pfennigstorf
Tested-by: Ingo Pfennigstorf
Reviewed-by: Stefan Galinski
Tested-by: Stefan Galinski
typo3/sysext/backend/Classes/Tree/Pagetree/DataProvider.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php

index 4628a9a..c30dc0f 100644 (file)
@@ -221,11 +221,25 @@ class DataProvider extends \TYPO3\CMS\Backend\Tree\AbstractTreeDataProvider {
                $isNumericSearchFilter = is_numeric($searchFilter) && $searchFilter > 0;
                $searchFilterQuoted = preg_quote($searchFilter, '/');
                $nodeId = intval($node->getId());
+               $processedRecordIds = array();
                foreach ($records as $record) {
-                       $record = Commands::getNodeRecord($record['uid']);
-                       if (intval($record['pid']) === -1 || in_array($record['uid'], $this->hiddenRecords)) {
+                       if (intval($record['t3ver_wsid']) !== intval($GLOBALS['BE_USER']->workspace) && intval($record['t3ver_wsid']) !== 0) {
                                continue;
                        }
+                       $liveVersion = BackendUtility::getLiveVersionOfRecord('pages', $record['uid'], 'uid');
+                       if ($liveVersion !== NULL) {
+                               $record = $liveVersion;
+                       }
+
+                       $record = Commands::getNodeRecord($record['uid'], FALSE);
+                       if (intval($record['pid']) === -1
+                               || in_array($record['uid'], $this->hiddenRecords)
+                               || in_array($record['uid'], $processedRecordIds)
+                       ) {
+                               continue;
+                       }
+                       $processedRecordIds[] = $record['uid'];
+
                        $rootline = BackendUtility::BEgetRootLine($record['uid'], '', $GLOBALS['BE_USER']->workspace != 0);
                        $rootline = array_reverse($rootline);
                        if ($nodeId === 0) {
@@ -265,7 +279,7 @@ class DataProvider extends \TYPO3\CMS\Backend\Tree\AbstractTreeDataProvider {
                                if (!$inFilteredRootline || intval($rootlineElement['uid']) === intval($mountPoint)) {
                                        continue;
                                }
-                               $rootlineElement = Commands::getNodeRecord($rootlineElement['uid']);
+                               $rootlineElement = Commands::getNodeRecord($rootlineElement['uid'], FALSE);
                                $ident = intval($rootlineElement['sorting']) . intval($rootlineElement['uid']);
                                if ($reference && $reference->offsetExists($ident)) {
                                        /** @var $refNode \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode */
@@ -452,7 +466,7 @@ class DataProvider extends \TYPO3\CMS\Backend\Tree\AbstractTreeDataProvider {
         */
        protected function getSubpages($id, $searchFilter = '') {
                $where = $this->getWhereClause($id, $searchFilter);
-               return $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'pages', $where, '', 'sorting', '', 'uid');
+               return $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,t3ver_wsid', 'pages', $where, '', 'sorting', '', 'uid');
        }
 
        /**
index 534ee98..eb1e591 100644 (file)
@@ -362,11 +362,17 @@ class BackendUtility {
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pid,uid,title,TSconfig,is_siteroot,storage_pid,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_stage,backend_layout_next_level', 'pages', 'uid=' . intval($uid) . ' ' . self::deleteClause('pages') . ' ' . $clause);
                        $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
                        if ($row) {
+                               $newLocation = FALSE;
                                if ($workspaceOL) {
                                        self::workspaceOL('pages', $row);
+                                       $newLocation = self::getMovePlaceholder('pages', $row['uid'], 'pid');
                                }
                                if (is_array($row)) {
-                                       self::fixVersioningPid('pages', $row);
+                                       if ($newLocation !== FALSE) {
+                                               $row['pid'] = $newLocation['pid'];
+                                       } else {
+                                               self::fixVersioningPid('pages', $row);
+                                       }
                                        $getPageForRootline_cache[$ident] = $row;
                                }
                        }