[BUGFIX] Fix fatal in web->view for page without access 86/44886/2
authorMichael Oehlhof <typo3@oehlhof.de>
Sat, 21 Nov 2015 20:57:41 +0000 (21:57 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Sun, 22 Nov 2015 09:19:00 +0000 (10:19 +0100)
Resolves: #71766
Releases: master
Change-Id: I3b8382e6b630f16ead5fd2133bb050fe4986ac8f
Reviewed-on: https://review.typo3.org/44886
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php

index 809813f..6e6c556 100644 (file)
@@ -118,39 +118,43 @@ class ViewModuleController extends ActionController
 
         $permissionClause = $this->getBackendUser()->getPagePermsClause(1);
         $pageRecord = BackendUtility::readPageAccess($pageIdToShow, $permissionClause);
-        $this->view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageRecord);
+        if ($pageRecord) {
+            $this->view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageRecord);
 
-        $adminCommand = $this->getAdminCommand($pageIdToShow);
-        $domainName = $this->getDomainName($pageIdToShow);
-        $languageParameter = $this->getLanguageParameter();
-        // Mount point overlay: Set new target page id and mp parameter
-        /** @var \TYPO3\CMS\Frontend\Page\PageRepository $sysPage */
-        $sysPage = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class);
-        $sysPage->init(false);
-        $mountPointMpParameter = '';
-        $finalPageIdToShow = $pageIdToShow;
-        $mountPointInformation = $sysPage->getMountPointInfo($pageIdToShow);
-        if ($mountPointInformation && $mountPointInformation['overlay']) {
-            // New page id
-            $finalPageIdToShow = $mountPointInformation['mount_pid'];
-            $mountPointMpParameter = '&MP=' . $mountPointInformation['MPvar'];
-        }
-        // Modify relative path to protocol with host if domain record is given
-        $protocolAndHost = '..';
-        if ($domainName) {
-            // TCEMAIN.previewDomain can contain the protocol, check prevents double protocol URLs
-            if (strpos($domainName, '://') !== false) {
-                $protocolAndHost = $domainName;
-            } else {
-                $protocol = 'http';
-                $page = (array)$sysPage->getPage($finalPageIdToShow);
-                if ($page['url_scheme'] == 2 || $page['url_scheme'] == 0 && GeneralUtility::getIndpEnv('TYPO3_SSL')) {
-                    $protocol = 'https';
+            $adminCommand = $this->getAdminCommand($pageIdToShow);
+            $domainName = $this->getDomainName($pageIdToShow);
+            $languageParameter = $this->getLanguageParameter();
+            // Mount point overlay: Set new target page id and mp parameter
+            /** @var \TYPO3\CMS\Frontend\Page\PageRepository $sysPage */
+            $sysPage = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class);
+            $sysPage->init(false);
+            $mountPointMpParameter = '';
+            $finalPageIdToShow = $pageIdToShow;
+            $mountPointInformation = $sysPage->getMountPointInfo($pageIdToShow);
+            if ($mountPointInformation && $mountPointInformation['overlay']) {
+                // New page id
+                $finalPageIdToShow = $mountPointInformation['mount_pid'];
+                $mountPointMpParameter = '&MP=' . $mountPointInformation['MPvar'];
+            }
+            // Modify relative path to protocol with host if domain record is given
+            $protocolAndHost = '..';
+            if ($domainName) {
+                // TCEMAIN.previewDomain can contain the protocol, check prevents double protocol URLs
+                if (strpos($domainName, '://') !== false) {
+                    $protocolAndHost = $domainName;
+                } else {
+                    $protocol = 'http';
+                    $page = (array)$sysPage->getPage($finalPageIdToShow);
+                    if ($page['url_scheme'] == 2 || $page['url_scheme'] == 0 && GeneralUtility::getIndpEnv('TYPO3_SSL')) {
+                        $protocol = 'https';
+                    }
+                    $protocolAndHost = $protocol . '://' . $domainName;
                 }
-                $protocolAndHost = $protocol . '://' . $domainName;
             }
+            return $protocolAndHost . '/index.php?id=' . $finalPageIdToShow . $this->getTypeParameterIfSet($finalPageIdToShow) . $mountPointMpParameter . $adminCommand . $languageParameter;
+        } else {
+            return '#';
         }
-        return $protocolAndHost . '/index.php?id=' . $finalPageIdToShow . $this->getTypeParameterIfSet($finalPageIdToShow) . $mountPointMpParameter . $adminCommand . $languageParameter;
     }
 
     /**