Shared mode only works with basic field

Created on 11 August 2022, over 2 years ago
Updated 18 April 2024, 7 months ago

Problem/Motivation

The current code assume that all fields used to compare the shared or not have a 'value' property which is prevent this mode to be used with entity reference fields.

Steps to reproduce

  1. Create content type A and B.
  2. Add an entity reference field on A and on user that reference to content type B.
  3. Create an access by reference rule by "Profile value" mode (shared) using the previous configuration.

When try to access content from content type A you will have a warning and no content filtering.

Warning: Undefined array key "value" in access_by_ref_node_access() (line 99 of modules/contrib/access_by_ref/access_by_ref.module).

Proposed resolution

Compare row field values instead of custom properties

Remaining tasks

Review and test patch.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France BΓ¨s

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.

  • πŸ‡ΈπŸ‡°Slovakia coaston

    Thank you, patch works fine.

  • Status changed to Fixed about 1 year ago
  • πŸ‡³πŸ‡±Netherlands Marceldeb

    Thanks, i applied the patch as it works the same way in the 3.x.x release.

    I will create a new release for 8.x-2.x branch but i recommend upgrading to 3.x.x.

  • Assigned to Marceldeb
  • πŸ‡³πŸ‡±Netherlands Marceldeb
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 7 months ago
  • πŸ‡ΈπŸ‡°Slovakia coaston

    Hm.
    I just installed 3.0.3 version and I can still see that issue :

    Warning: Undefined array key "value" in access_by_ref_node_access() (line 112 of modules/contrib/access_by_ref/access_by_ref.module).
    access_by_ref_node_access(Object, 'view', Object)
    call_user_func_array(Object, Array) (Line: 409)
    Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'access_by_ref') (Line: 388)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith('node_access', Object) (Line: 416)
    Drupal\Core\Extension\ModuleHandler->invokeAll('node_access', Array) (Line: 101)
    Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 101)
    Drupal\node\NodeAccessControlHandler->access(Object, 'view', Object, 1) (Line: 739)
    Drupal\Core\Entity\ContentEntityBase->access('view', Object, 1) (Line: 196)
    Drupal\node\Entity\Node->access('view', Object, 1) (Line: 68)
    Drupal\Core\Entity\EntityAccessCheck->access(Object, Object, Object)
    call_user_func_array(Array, Array) (Line: 160)
    Drupal\Core\Access\AccessManager->performCheck('access_check.entity', Object) (Line: 136)
    Drupal\Core\Access\AccessManager->check(Object, Object, Object, 1) (Line: 113)
    Drupal\Core\Access\AccessManager->checkRequest(Object, Object, 1) (Line: 107)
    Drupal\Core\Routing\AccessAwareRouter->checkAccess(Object) (Line: 92)
    Drupal\Core\Routing\AccessAwareRouter->matchRequest(Object) (Line: 105)
    Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest(Object, 'kernel.request', Object)
    call_user_func(Array, Object, 'kernel.request', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.request') (Line: 157)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
Production build 0.71.5 2024