[FOLLOWUP][TASK] Reduce SQL queries of page tree in workspaces 53/41553/2
authorNicole Cordes <typo3@cordes.co>
Fri, 17 Jul 2015 09:57:51 +0000 (11:57 +0200)
committerNicole Cordes <typo3@cordes.co>
Fri, 17 Jul 2015 12:02:21 +0000 (14:02 +0200)
The patch adds a check if workspaces is activated before using its
class and function.

Releases: 6.2
Resolves: #50349
Resolves: #66231
Related: #61184
Change-Id: I12bc2d496f2216725ac97a8640bc6c431630cc7a
Reviewed-on: http://review.typo3.org/41553
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/backend/Classes/Tree/View/AbstractTreeView.php

index 02f686b..a655fcf 100644 (file)
@@ -16,8 +16,8 @@ namespace TYPO3\CMS\Backend\Tree\View;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Workspaces\Service\WorkspaceService;
 
 /**
  * Base class for creating a browsable array/page/folder tree in HTML
@@ -969,7 +969,7 @@ abstract class AbstractTreeView {
                        }
                        // Passing on default <td> class for subelements:
                        if (is_array($row) && $subCSSclass !== '') {
-                               if ($this->table === 'pages' && $this->highlightPagesWithVersions && !isset($row['_CSSCLASS']) && $this->getWorkspaceService()->hasPageRecordVersions($this->BE_USER->workspace, $row['uid'])) {
+                               if ($this->table === 'pages' && $this->highlightPagesWithVersions && !isset($row['_CSSCLASS']) && $this->hasPageRecordVersions($this->BE_USER->workspace, $row['uid'])) {
                                        $row['_CSSCLASS'] = 'ver-versions';
                                }
                                if (!isset($row['_CSSCLASS'])) {
@@ -1042,7 +1042,21 @@ abstract class AbstractTreeView {
        }
 
        /**
-        * @return WorkspaceService
+        * @param int $workspaceId
+        * @param int $pageId
+        * @return bool
+        */
+       protected function hasPageRecordVersions($workspaceId, $pageId) {
+               if (!ExtensionManagementUtility::isLoaded('workspaces')) {
+                       return FALSE;
+               }
+
+               return $this->getWorkspaceService()->hasPageRecordVersions($workspaceId, $pageId);
+
+       }
+
+       /**
+        * @return \TYPO3\CMS\Workspaces\Service\WorkspaceService;
         */
        protected function getWorkspaceService() {
                if ($this->workspaceService === NULL) {