Commit 8b684be7 authored by dpi's avatar dpi Committed by Berdir
Browse files

Issue #3059012 by dpi: Catch exceptions thrown by toUrl and getInternalPath

parent 176b576d
......@@ -5,6 +5,8 @@ namespace Drupal\pathauto;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityMalformedException;
use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException;
use Drupal\Core\Entity\RevisionableInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageInterface;
......@@ -159,7 +161,21 @@ class PathautoGenerator implements PathautoGeneratorInterface {
return NULL;
}
$source = '/' . $entity->toUrl()->getInternalPath();
try {
$internalPath = $entity->toUrl()->getInternalPath();
}
// @todo convert to multi-exception handling in PHP 7.1.
catch (EntityMalformedException $exception) {
return NULL;
}
catch (UndefinedLinkTemplateException $exception) {
return NULL;
}
catch (\UnexpectedValueException $exception) {
return NULL;
}
$source = '/' . $internalPath;
$config = $this->configFactory->get('pathauto.settings');
$langcode = $entity->language()->getId();
......
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