Skip to content

Commit

Permalink
Correctly handle invalid page ID
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jun 7, 2021
1 parent 31a92e0 commit da7470a
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Terminal42\ChangeLanguage\EventListener;

use Contao\Controller;
use Contao\PageModel;
use Terminal42\ChangeLanguage\PageFinder;

class InsertTagsListener
Expand All @@ -33,7 +34,12 @@ public function onReplaceInsertTags($insertTag)

try {
$pageFinder = new PageFinder();
$currentPage = \PageModel::findByIdOrAlias($parts[1]);
$currentPage = PageModel::findByIdOrAlias($parts[1]);

if (null === $currentPage) {
return '';
}

$targetPage = $pageFinder->findAssociatedForLanguage($currentPage, $parts[2]);
} catch (\RuntimeException $e) {
// parent page of current page not found or not published
Expand Down

0 comments on commit da7470a

Please sign in to comment.