TypeError when NULL $entity passed to paragraphs_paragraphs_item_access()

Created on 3 August 2022, over 2 years ago
Updated 5 June 2023, over 1 year ago

Problem/Motivation

A type declaration was added to the arguments of the paragraphs_paragraphs_item_access() function requiring the $entity parameter to be of type ParagraphsItemEntity.

function paragraphs_paragraphs_item_access(ParagraphsItemEntity $entity, $op, $account) {

This causes a PHP TypeError exception when the $entity parameter is NULL. It looks like the type declaration was added in this patch: https://www.drupal.org/project/paragraphs/issues/2854100#comment-13344509 β†’

Steps to reproduce

Call the access() function from the EntityValueWrapper of a property of an entity that has a paragraphs field.

EntityValueWrapper->access('view')

In my case, I encountered this issue when using RESTful Web services module (restws) and trying to query for a node resource with a paragraphs field.

Proposed resolution

Make the $entity argument for paragraphs_paragraphs_item_access nullable.

function paragraphs_paragraphs_item_access(?ParagraphsItemEntity $entity, $op, $account) {

Remaining tasks

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States timothywang

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

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