Call to a member function bundle() on null

Created on 17 January 2024, 11 months ago
Updated 20 September 2024, 3 months ago

Problem/Motivation

Hi! I've encountered an error using this module together with module Trash.

Error: Call to a member function bundle() on null in Drupal\paragraphs_report\ParagraphsReport->getParasFromNid() (line 333 of modules/contrib/paragraphs_report/src/ParagraphsReport.php).

It happens when you assume the load method from Storage is going to load the node entity. In my case, the load of the entity has NULL result because it's in the trash. So, this error produces an exception.

Steps to reproduce

- Drupal 10.1
- Php 8.1
- Module Trash installed

1. Delete a node. (the node will be moved to the trash bin)
2. You get the error.

Proposed resolution

In my opinion, there must be some control for when the entity cannot be loaded. Or at least, a try/catch for the exception.
For now, and for my case, I applied a little patch to return the original array when the node can't be loaded. But I am sure there will be a better solution.

Remaining tasks

Please, review and feel free to comment your ideas.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain missvengerberg

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

Comments & Activities

Production build 0.71.5 2024