[BUGFIX] Pagetree filtering crashes on draft moves
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Tree / Pagetree / DataProvider.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');
        }
 
        /**