Commit 04a8e380 authored by Kevin Ditscheid's avatar Kevin Ditscheid

[TASK] Make the exceptions be a little more sane

parent 2c71d063
......@@ -30,6 +30,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Site\SiteFinder;
......@@ -125,7 +126,6 @@ class FrontendServices extends AbstractServices implements SingletonInterface {
* @param $element
* @param $lUid
* @return mixed
* @throws Exception
*/
public static function getOverlayLanguageIdForElement($element, $lUid) {
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
......@@ -138,11 +138,15 @@ class FrontendServices extends AbstractServices implements SingletonInterface {
try {
$site = $siteFinder->getSiteByPageId($pid);
} catch (Exception $e) {
} catch (SiteNotFoundException $e) {
return FALSE;
}
$language = $site->getLanguageById($lUid);
try {
$language = $site->getLanguageById($lUid);
} catch (\InvalidArgumentException $e) {
return FALSE;
}
if (!$language instanceof SiteLanguage) {
return FALSE;
......
......@@ -70,7 +70,6 @@ class VisibilityService implements SingletonInterface {
* @param SiteLanguage $language
* @param Element $element
* @return mixed
* @throws \Exception
*/
public function getOverlayLanguageIdForLanguageAndElement(SiteLanguage $language, Element $element) {
if ($this->isVisible($language, $element)) {
......@@ -123,7 +122,6 @@ class VisibilityService implements SingletonInterface {
* @param SiteLanguage $language
* @param Element $element
* @return boolean
* @throws \Exception
*/
public function isVisible(SiteLanguage $language, Element $element): bool {
$this->_relevantOverlayLanguageId = $language->getLanguageId();
......@@ -140,7 +138,6 @@ class VisibilityService implements SingletonInterface {
* @param $language
* @param $element
* @return bool
* @throws \Exception
*/
public function resolveVisibility($visibility, $language, $element): bool {
......@@ -249,7 +246,6 @@ class VisibilityService implements SingletonInterface {
* @param SiteLanguage $language
* @param Element $element
* @return string
* @throws DBALException
*/
public function getVisibilitySetting(SiteLanguage $language, Element $element): string {
......@@ -289,7 +285,6 @@ class VisibilityService implements SingletonInterface {
* @param SiteLanguage $language
* @param Element $element
* @return Visibility
* @throws DBALException
*/
protected function getVisibility(SiteLanguage $language, Element $element): Visibility {
$visibility = new Visibility();
......@@ -371,19 +366,18 @@ class VisibilityService implements SingletonInterface {
*
* @param $languageUid
* @return string
* @throws DBALException
*/
protected function getDefaultVisibilityForPagesByLanguage($languageUid): string {
if ($this->cachedDefaultVisibilityForPages === NULL) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('sys_language');
$results = $queryBuilder->prepare('SELECT uid FROM sys_language');
->getQueryBuilderForTable('sys_language');
$results = $queryBuilder->select('uid')
->from('sys_language')
->execute();
$this->cachedDefaultVisibilityForPages[0] = 'fallback';
if ($results->execute()) {
foreach ($results->fetchAll() as $entry) {
$this->cachedDefaultVisibilityForPages[$entry['uid']] = 'active';
}
while ($entry = $results->fetch()) {
$this->cachedDefaultVisibilityForPages[$entry['uid']] = 'active';
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment