Blocks cause WSOD; Cannot generate default URL

Created on 14 January 2024, 10 months ago
Updated 13 February 2024, 9 months ago

Problem/Motivation

Placing a block containing a feed causes the page where the block is placed to error.

Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: Cannot generate default URL because no link template 'canonical' or 'edit-form' was found for the 'aggregator_item' entity type in Drupal\Core\Entity\EntityBase->toUrl() (line 176 of /home/website/test_html/web/core/lib/Drupal/Core/Entity/EntityBase.php).

The problem call to toURL() is in src/Plugin/Block/AggregatorFeedBlock.php

To fix, change

      foreach ($items as $item) {
        try {
          $build['list']['#items'][$item->id()] = [
            '#type' => 'link',
            '#url' => $item->toUrl(),
            '#title' => $item->label(),
          ];
        }

to

      foreach ($items as $item) {
        try {
          $build['list']['#items'][$item->id()] = [
            '#type' => 'link',
            '#url' => $item->toUrl('canonical'),
            '#title' => $item->label(),
          ];
        }
πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom John_B London (UK), Worthing (UK), Innsbruck (Tirol)

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024