bihor / backendtools

9 admin tools for extensions, slugs, redirects, files, images and links.
GNU General Public License v3.0
5 stars 3 forks source link

Catch SiteNotFound exception for pages without site configuration #4

Closed netcoop closed 4 years ago

netcoop commented 4 years ago

If you have folders outside the site root pages containing content, or inconsistencies like lost pages whose parent has been deleted, then this fix catches the exception and backendtools keeps working.

bihor commented 4 years ago

Thanks a lot for this bugfix.

bihor commented 4 years ago

Well, I have now tried the bugfix, but I still get an error TYPO3\CMS\Core\Exception\SiteNotFoundException for pages with no siteroot. Any idea?

bihor commented 4 years ago

I have found a way. For me, it works only so: try { $rootLineUtility = new \TYPO3\CMS\Core\Utility\RootlineUtility($row['pid']); $rootline = $rootLineUtility->get(); $root = array_pop($rootline); $row['root'] = $root['uid']; //$row['domain'] = $domains[$root['uid']]; if ($root['is_siteroot']) { $site = $siteFinder->getSiteByPageId($root['uid']); // oder $row['pid']); $base = $site->getConfiguration()['base']; $row['domain'] = rtrim($base, '/'); } else { $row['domain'] = ''; } } catch (SiteNotFoundException $e) { $row['domain'] = ''; }