Skip to content

Commit

Permalink
Fix a potential PHP 8 error in missing language icon listener if the …
Browse files Browse the repository at this point in the history
…returned model is null
  • Loading branch information
qzminski committed Mar 10, 2022
1 parent 9314351 commit 18d7607
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/EventListener/DataContainer/MissingLanguageIconListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ public function onPageLabel(array $args, $previousResult = null)
return $label;
}

$page = PageModel::findWithDetails($row['id']);
$root = PageModel::findByPk($page->rootId);

if (
(!$root->fallback || $root->languageRoot > 0)
($page = PageModel::findWithDetails($row['id'])) !== null
&& ($root = PageModel::findByPk($page->rootId)) !== null
&& (!$root->fallback || $root->languageRoot > 0)
&& (!$page->languageMain || null === PageModel::findByPk($page->languageMain))
) {
return $this->generateLabelWithWarning($label);
Expand All @@ -91,17 +90,15 @@ public function onArticleLabel(array $args, $previousResult = null)
$label = $previousResult;
}

if ($row['showTeaser']) {
$page = PageModel::findWithDetails($row['pid']);
$root = PageModel::findByPk($page->rootId);

if (
(!$root->fallback || $root->languageRoot > 0)
&& $page->languageMain > 0 && null !== PageModel::findByPk($page->languageMain)
&& (!$row['languageMain'] || null === ArticleModel::findByPk($row['languageMain']))
) {
return $this->generateLabelWithWarning($label);
}
if (
$row['showTeaser']
&& ($page = PageModel::findWithDetails($row['pid'])) !== null
&& ($root = PageModel::findByPk($page->rootId)) !== null
&& (!$root->fallback || $root->languageRoot > 0)
&& $page->languageMain > 0 && null !== PageModel::findByPk($page->languageMain)
&& (!$row['languageMain'] || null === ArticleModel::findByPk($row['languageMain']))
) {
return $this->generateLabelWithWarning($label);
}

return $label;
Expand All @@ -126,8 +123,9 @@ public function onNewsChildRecords(array $args, $previousResult = null)
$archive = NewsArchiveModel::findByPk($row['pid']);

if (
$archive->master &&
(!$row['languageMain'] || null === NewsModel::findByPk($row['languageMain']))
$archive !== null
&& $archive->master
&& (!$row['languageMain'] || null === NewsModel::findByPk($row['languageMain']))
) {
return $this->generateLabelWithWarning($label);
}
Expand All @@ -150,7 +148,8 @@ public function onCalendarEventChildRecords(array $args, $previousResult = null)
$calendar = CalendarModel::findByPk($row['pid']);

if (
$calendar->master
$calendar !== null
&& $calendar->master
&& (!$row['languageMain'] || null === CalendarEventsModel::findByPk($row['languageMain']))
) {
return $this->generateLabelWithWarning($label);
Expand All @@ -174,7 +173,8 @@ public function onFaqChildRecords(array $args, $previousResult = null)
$category = FaqCategoryModel::findByPk($row['pid']);

if (
$category->master
$category !== null
&& $category->master
&& (!$row['languageMain'] || null === FaqModel::findByPk($row['languageMain']))
) {
return preg_replace(
Expand Down

0 comments on commit 18d7607

Please sign in to comment.