Undefined method getContentByEntityId()

Created on 9 June 2023, over 1 year ago
Updated 27 July 2023, over 1 year ago

Problem/Motivation

When updating or creating of node following error occurs:

Error: Call to undefined method Drupal\group\Entity\Group::getContentByEntityId() in content_to_group_node_insert() (line 51 of /var/www/pxsm/web/modules/contrib/content_to_group/content_to_group.module)

Steps to reproduce

Proposed resolution

Change method according https://www.drupal.org/node/3293040

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇪🇸Spain qpro Spain

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

Comments & Activities

  • Issue created by @qpro
  • First commit to issue fork.
  • @sakthi_dev opened merge request.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India sakthi_dev

    Please review.

  • 🇪🇸Spain qpro Spain

    Reviewed, get this error:

    TypeError: array_keys(): Argument #1 ($array) must be of type array, null given in array_keys() (line 37 of /var/www/pxsm/web/modules/contrib/content_to_group/content_to_group.module)
    #0 /var/www/pxsm/web/modules/contrib/content_to_group/content_to_group.module(37): array_keys()
    #1 [internal function]: content_to_group_node_insert()
    #2 /var/www/pxsm/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(426): call_user_func_array()
    #3 /var/www/pxsm/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
    #4 /var/www/pxsm/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(433): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
    #5 /var/www/pxsm/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(249): Drupal\Core\Extension\ModuleHandler->invokeAll()
    #6 /var/www/pxsm/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(900): Drupal\Core\Entity\EntityStorageBase->invokeHook()
    #7 /var/www/pxsm/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(598): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook()
    #8 /var/www/pxsm/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(781): Drupal\Core\Entity\EntityStorageBase->doPostSave()
    #9 /var/www/pxsm/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(523): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave()
    #10 /var/www/pxsm/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(804): Drupal\Core\Entity\EntityStorageBase->save()
    #11 /var/www/pxsm/web/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
    #12 /var/www/pxsm/web/core/modules/node/src/NodeForm.php(270): Drupal\Core\Entity\EntityBase->save()
    #13 [internal function]: Drupal\node\NodeForm->save()
    #14 /var/www/pxsm/web/core/lib/Drupal/Core/Form/FormSubmitter.php(114): call_user_func_array()
    #15 /var/www/pxsm/web/core/lib/Drupal/Core/Form/FormSubmitter.php(52): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()
    #16 /var/www/pxsm/web/core/lib/Drupal/Core/Form/FormBuilder.php(597): Drupal\Core\Form\FormSubmitter->doSubmitForm()
    #17 /var/www/pxsm/web/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm()
    #18 /var/www/pxsm/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
    #19 /var/www/pxsm/web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
    #20 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
    #21 /var/www/pxsm/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
    #22 /var/www/pxsm/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #23 /var/www/pxsm/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
    #24 /var/www/pxsm/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
    #25 /var/www/pxsm/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #26 /var/www/pxsm/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #27 /var/www/pxsm/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
    #28 /var/www/pxsm/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #29 /var/www/pxsm/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #30 /var/www/pxsm/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
    #31 /var/www/pxsm/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #32 /var/www/pxsm/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #33 /var/www/pxsm/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #34 /var/www/pxsm/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
    #35 /var/www/pxsm/web/index.php(19): Drupal\Core\DrupalKernel->handle()
    #36 {main}

  • Assigned to arpitk
  • Status changed to Needs work over 1 year ago
  • 🇮🇳India arpitk

    I am getting other error on saving the node.
    Error: Class "Drupal\content_to_group\Util\ContentToGroupUtility" not found in content_to_group_node_insert() (line 39 of /app/web/modules/contrib/content_to_group/content_to_group.module)

  • Issue was unassigned.
  • 🇪🇸Spain qpro Spain

    In case it helps someone, this is the module that can cover this functionality while this issue is unsolved https://www.drupal.org/project/entitygroupfield . Since yesterday a new release, compatible with Groups v2 and v3, is availiable.

  • 🇸🇳Senegal diaodiallo

    I think this patch should work, fixing the getContentByEntityId() & the #5 issues.

    @qpro I am making sure #5 is not happing however you are supposed to select the content type in this config form /admin/config/content-to-group-settings that's why this was happening.

    @arpitk I am not sure why this is happening, however can you check again with this patch?

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India arpitk

    Thanks @diaodiallo patch #10 applied cleanly and now i see no error.

  • 🇸🇳Senegal diaodiallo

    More complete patch which works with Group 1.x, 2.0.x and 3.0.x.

    In fact for our case addContent() and getContentByEntityId() do no longer exist in version 2 and 3 of the Group module. The groupContent entity is also replaced by the groupRelationship.

    I tested this patch on Group 1.x and 2.0 but is supposed to work with 3.0. Waiting for more feedback.

    • diaodiallo authored af536c67 on 1.0.x
      Issue #3365812 by diaodiallo, sakthi_dev, arpitk, qpro: Undefined method...
  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024