Fatal error when editing entity field

Created on 3 October 2023, over 1 year ago

Problem/Motivation

Can't edit fields with this module enabled.

Steps to reproduce

When editing Entity reference field, I've got the following error:

Fatal error: Declaration of Drupal\field_permissions_group\Plugin\FieldPermissionType\CustomGroupAccess::create(Symfony\Component\DependencyInjection\ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, ?Drupal\field\FieldConfigInterface $field_config = null) must be compatible with Drupal\field_permissions\Plugin\FieldPermissionType\Base::create(Symfony\Component\DependencyInjection\ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, ?Drupal\field\FieldStorageConfigInterface $field_storage = null) in /var/www/html/web/modules/contrib/field_permissions_group/src/Plugin/FieldPermissionType/CustomGroupAccess.php on line 70
๐Ÿ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom kenorb

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

Merge Requests

Comments & Activities

  • Issue created by @kenorb
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom kenorb
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Istari

    Anything new with this error?
    I'm facing the same issue.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Istari

    I did a little research within the code and found out, that the function CustomGroupAccess::create( ) needs the argument FieldStorageConfigInterface $field_storage, based on the Base class (Base.php) which it is inherited from.

    So before:

      public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, FieldConfigInterface $field_config = NULL) {
        return new static(
          $configuration,
          $plugin_id,
          $plugin_definition,
          $field_config,
          $container->get('field_permissions.permissions_service'),
          $container->get('plugin.manager.group_content_enabler')
        );
      }

    And after the changes:

      public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, FieldStorageConfigInterface $field_storage = NULL) {
        return new static(
          $configuration,
          $plugin_id,
          $plugin_definition, 
          $field_storage ,
          $container->get('field_permissions.permissions_service'),
          $container->get('plugin.manager.group_content_enabler')
        );
      }

    Changing this comes with a new follow up error that says:

    Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "plugin.manager.group_content_enabler". in Drupal\Component\DependencyInjection\Container->get() (line 157 of core/lib/Drupal/Component/DependencyInjection/Container.php).

    So taking a look into the field_permissions_group.service.yml, field_permissions_group.services.yml, and group.services.yml neither shows a similar defined service or with similar logic.

    I'd like to fix this issue, but my knowledge is far beyond of the understanding of this, cause I'm pretty new to Drupal.
    But maybe this is a help for someone more experienced like me who may fixing it or giving a hint into the right direction :P

    I hope it helps :)

  • First commit to issue fork.
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine pablo_pukha

    I write patch for this module. This patch fix problem for new group version

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia abhishek_virasat

    @kenorb, I have fix the issue pls kindly review the MR

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Hydra

    I adjusted the issue metadata, because it's about making this module compatible with the 3.x version of group. The maintainers need to make sure that a new version of this module is tagged and the module page gives information about that.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Istari

    I have tested the patch and it comes to a thrown error:

    Error: Call to a member function getName() on null in Drupal\field_permissions_group\Plugin\FieldPermissionType\CustomGroupAccess->hasFieldAccess() (line 95 of modules/contrib/field_permissions_group/src/Plugin/FieldPermissionType/CustomGroupAccess.php).
    Drupal\field_permissions\FieldPermissionsService->getFieldAccess('view', Object, Object, Object) (Line: 39)
    field_permissions_entity_field_access('view', Object, Object, Object) (Line: 350)
    Drupal\Core\Entity\EntityAccessControlHandler->Drupal\Core\Entity\{closure}(Object, 'field_permissions') (Line: 388)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_field_access', Object) (Line: 351)
    Drupal\Core\Entity\EntityAccessControlHandler->fieldAccess('view', Object, Object, Object, 1) (Line: 154)
    Drupal\Core\Field\FieldItemList->access('view', NULL, 1) (Line: 253)
    Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 268)
    Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple(Array) (Line: 339)
    Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 281)
    Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 238)
    Drupal\Core\Entity\EntityViewBuilder->build(Array)
    call_user_func_array(Array, Array) (Line: 111)
    Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 797)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 386)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
    Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
    call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
    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: 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: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    Steps to reproduce
    - Create group
    - Create insider and outsider role
    - Make sure to have admin access to group
    - Create two testing field types (A and B)
    - assign view access to insider for field type A
    - assign no access to insider for field type B
    - open group page (/group/id)

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine pablo_pukha

    I updated my patch

  • Pipeline finished with Skipped
    over 1 year ago
    #62702
  • First commit to issue fork.
  • Pipeline finished with Skipped
    over 1 year ago
    #62704
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Islanderweedy
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Hydra

    @Islanderweedy I don't think it's a good idea to commit this to the 1.0.x branch. There are still a lot of people out there using group 1, which got extended support for D10.
    This would break all those group1 sites using your module.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine alt.dev

    When I apply this patch and try to add fields to the group content, I receive the next error:

    Drupal\Core\Entity\EntityStorageException: 'group_relationship_type' entity with ID 'community-group_node-record' already exists. in Drupal\Core\Entity\EntityStorageBase->doPreSave() (line 519 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).

    Attaching an updated patch that solves this issue.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany geek-merlin Freiburg, Germany

    geek-merlin โ†’ changed the visibility of the branch 3391457-fatal-error-when to hidden.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States pdcarto

    The updated patch โ†’ works for me - fixes this issue with group v2.2.2

  • I think there was update on July 17th and patch no longer applies.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States kreynen

    This patch was used in a project we inherited. I don't know enough about the Group module and the updates to this project to know how much of this is still needed, but the MR I suggested in ๐Ÿ› Drupal\field_permissions_group\Plugin\FieldPermissionType\CustomGroupAccess::create(Object, Array, 'custom_group', Array, Object) (Line: 58) Active is enough to get the admin/modules UI rendering again.

  • ๐Ÿ‡ป๐Ÿ‡ณVietnam thaoquang

    @denist3r patch still error:

    TypeError: array_keys(): Argument #1 ($array) must be of type array, null given in array_keys() (line 75 of drupal_11/modules/contrib/field_permissions/src/Plugin/FieldPermissionType/CustomAccess.php).
    

    Backtrace:

    #0 /drupal_11/modules/contrib/field_permissions/src/Plugin/FieldPermissionType/CustomAccess.php(75): array_keys(NULL)
    #1 /drupal_11/modules/contrib/field_permissions/field_permissions.module(178): Drupal\field_permissions\Plugin\FieldPermissionType\CustomAccess->submitAdminForm(Array, Object(Drupal\Core\Form\FormState), Object(Drupal\user\RoleStorage))
    #2 [internal function]: field_permissions_field_config_edit_form_submit(Array, Object(Drupal\Core\Form\FormState))
    #3 /drupal_11/core/lib/Drupal/Core/Form/FormSubmitter.php(105): call_user_func_array('field_permissio...', Array)
    #4 /drupal_11/core/lib/Drupal/Core/Form/FormSubmitter.php(43): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
    #5 /drupal_11/core/lib/Drupal/Core/Form/FormBuilder.php(589): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
    #6 /drupal_11/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder->processForm('field_config_ed...', Array, Object(Drupal\Core\Form\FormState))
    #7 /drupal_11/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\field_ui\Form\FieldConfigEditForm), Object(Drupal\Core\Form\FormState))
    #8 /drupal_11/core/modules/field_ui/src/Controller/FieldConfigAddController.php(62): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\field\Entity\FieldConfig), 'default', Array)
    #9 [internal function]: Drupal\field_ui\Controller\FieldConfigAddController->fieldConfigAddConfigureForm('group', 'field_private_e...')
    #10 /drupal_11/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
    #11 /drupal_11/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #12 /drupal_11/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #13 /drupal_11/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
    #14 /drupal_11/vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #15 /drupal_11/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #16 /drupal_11/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #17 /drupal_11/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #18 /drupal_11/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #19 /drupal_11/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #20 /drupal_11/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #21 /drupal_11/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #22 /drupal_11/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #23 /drupal_11/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #24 /drupal_11/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #25 /drupal_11/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #26 /drupal_11/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #27 /drupal_11/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #28 {main}
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand jlscott

    jayelless โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand jlscott

    Branch 3.0.x of this module is now compatible with Group v3.

Production build 0.71.5 2024