Skip to content
Snippets Groups Projects

Views UI link generation may also throw BadRequestException.

4 files
+ 9
5
Compare changes
  • Side-by-side
  • Inline

Files

@@ -16,6 +16,7 @@
use Drupal\Core\Url;
use Drupal\views\Views;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
use Drupal\Core\Extension\ModuleHandlerInterface;
@@ -464,7 +465,7 @@ public function getDisplayDetails($view, $display) {
if ($path && (!str_contains($path, '%'))) {
// Wrap this in a try/catch as trying to generate links to some
// routes may throw a NotAcceptableHttpException if they do not
// routes may throw an exception, for example if they do not
// respond to HTML, such as RESTExports.
try {
if (!parse_url($path, PHP_URL_SCHEME)) {
@@ -476,7 +477,7 @@ public function getDisplayDetails($view, $display) {
$url = Url::fromUri("base:$path");
}
}
catch (NotAcceptableHttpException $e) {
catch (BadRequestException | NotAcceptableHttpException $e) {
$url = '/' . $path;
}
Loading