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

Issue fork paragraphs-3301655

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

timothywang created an issue. See original summary.

immaculatexavier made their first commit to this issue’s fork.

immaculatexavier’s picture

Status: Active » Needs review

Committed with MR in accordance to the proposed resolution

vinmassaro’s picture

Status: Needs review » Reviewed & tested by the community

Ran into an issue where the Rules overview page would no longer load. Patch fixed the issue, thanks. Moving to RTBC