Fatal error when path does not exist

Created on 20 November 2020, almost 4 years ago
Updated 30 August 2024, 3 months ago

Problem/Motivation

The module uses the current path to build the links. Under some circumstances

$url_object = \Drupal::service('path.validator')->getUrlIfValid($current_path);

returns FALSE instead of an URL object, therefore we get a fatal error next line:

Error: Call to a member function getRouteName() on boolean in Drupal\readmore\Plugin\Field\FieldFormatter\ReadmoreFormatter->viewElements()

One situation is:

  • Using a Block content which is configured to use the readmore and place it on a page which is configured to be the 404 page.

Steps to reproduce

  • Create a new content block type with a body field configured to use the readmore formatter
  • Create an instance of this block and place it on a page
  • Configure the page to be one used on 404
  • Type a non existing page on the URL. As a result the error is thrown
πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain jlbellido

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024