diff --git a/components/SEOBundle/bundle/Core/MetaNameSchema.php b/components/SEOBundle/bundle/Core/MetaNameSchema.php index 1ab0bd939..8909e2440 100644 --- a/components/SEOBundle/bundle/Core/MetaNameSchema.php +++ b/components/SEOBundle/bundle/Core/MetaNameSchema.php @@ -37,6 +37,8 @@ use Ibexa\Core\Repository\Values\Content\VersionInfo; use Ibexa\FieldTypeRichText\FieldType\RichText\Value as RichTextValue; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; class MetaNameSchema extends NameSchemaService { @@ -83,6 +85,7 @@ public function __construct( RepositoryInterface $repository, TranslationHelper $translationHelper, ConfigResolverInterface $configurationResolver, + ?LoggerInterface $logger = null, array $settings = [] ) { $this->fieldTypeRegistry = $fieldTypeRegistry; @@ -99,6 +102,7 @@ public function __construct( $this->translationHelper = $translationHelper; $this->relationListField = $this->fieldTypeRegistry->getFieldType('ezobjectrelationlist'); $this->configurationResolver = $configurationResolver; + $this->logger = $logger ?? new NullLogger(); } public function setRichTextConverter(RichTextConverterInterface $richTextConverter): void @@ -266,8 +270,16 @@ protected function handleRelationValue(RelationValue $value, string $languageCod if (!$value->destinationContentId) { return ''; } - $relatedContent = $this->repository->getContentService()->loadContent($value->destinationContentId); - // @todo: we can probably be better here and handle more than just "image" + //if the content is not translated + try { + $relatedContent = $this->repository->getContentService()->loadContent($value->destinationContentId); + } catch (\Exception $e) { + $this->logger->error($e->getMessage(), [ + 'exception' => $e, + ]); + return ''; + } + // @todo: we can probably be better here and handle more than just "image" $fieldImageValue = $relatedContent->getFieldValue('image'); if ($fieldImageValue instanceof ImageValue) { if ($fieldImageValue->uri) {