Steps to reproduce:

1.- In a node with paragraphs, add a new paragraph item but don't save the node yet.
3.- Click Preview button.

You will receive the follow error:

"TypeError: Argument 2 passed to Drupal\permissions_by_term\Cache\AccessResultCache::hasAccessResultsCache() must be of the type int, null given, called in /var/www/html/project/docroot/modules/contrib/permissions_by_term/modules/permissions_by_entity/permissions_by_entity.module on line 26 in Drupal\permissions_by_term\Cache\AccessResultCache->hasAccessResultsCache() (line 61 of modules/contrib/permissions_by_term/src/Cache/AccessResultCache.php)."

The problem:
In the line 26 ist not being checked if the entity is new or already exists. In this case, the new paragraph has not been saved yet and doesn't have an id.

if ($operation === 'view' && $entity instanceof FieldableEntityInterface) {

The if condition should check whether the entity is a new entity or not.

if ($operation === 'view' && $entity instanceof FieldableEntityInterface && !$entity->isNew()) {

Regards

Comments

juagarc4 created an issue. See original summary.

juagarc4’s picture

Title: Error on preview a node without unsaved paragraphs » Error on preview a node with unsaved paragraphs
juagarc4’s picture

jepster_’s picture

Status: Active » Needs work

@juagarc4: Thanks for sharing your thoughts!

I could not reproduce that on a bare Drupal instance with latest PbT and Paragraphs installed. It might be related to any project specifics:

Only local images are allowed.

However, the extended check is good. I will apply it.

jepster_’s picture

Status: Needs work » Fixed

The patch is applied and contained in PbT version 8.x-2.24: https://www.drupal.org/project/permissions_by_term/releases/8.x-2.24

Thanks!

jepster_’s picture

Status: Fixed » Closed (fixed)