In NodeAddToAnyShare validte if entity is a Node Entity before render

Created on 15 April 2025, 14 days ago

Problem/Motivation

Sometimes when AddToAny share buttons field is used in Views, the render method fails with the following message

Uncaught PHP Exception Error: "Call to a member function access() on null" at web/modules/contrib/addtoany/src/Plugin/views/field/NodeAddToAnyShare.php line 29

It's happened when values to render aren't entity node objects.

Proposed resolution

Add a validation before rendering in the same if of check access.

if ($entity->access('view')) {

New Validation:

if ($entity instanceof \Drupal\Core\Entity\EntityInterface && $entity->access('view')) {

Remaining tasks

  • Create fork
  • Add validation in code
  • Propose merge request
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇨🇴Colombia aldibier Manizales

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