Adding node into the Groups throwing exception - Group Nodes

Created on 23 August 2024, 3 months ago

Problem/Motivation

Getting below error on creating node inside the Group Node on Drupal 10.4.x-dev.

The website encountered an unexpected error. Try again later.

Drupal\Core\Entity\EntityStorageException: This entity can only be saved in the default workspace. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
workspaces_entity_presave()
call_user_func_array() (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 415)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 217)

Steps to reproduce

1. Install and enable the following modules: Group, Group Node
2. Create the Group type and Enable content type Article on Content(Entities that can be added to this group type).
3. Keep uncheck for Use 2-step wizard when creating a new Content
3. Switch to Stage (or any other) workspace.
4. Goto the group/GROUP_ID/nodes and goto node add /group/GROUP_ID/content/create/group_node/article
5. On saving you can able to see the error.
6. Node created successfully but not added to the Group.

Proposed resolution

The Workspaces support the core content node entity but Workspaces do not support the Group entity.

Due to that, a node was created but not attached to the Group.

If you are keeping Use 2-step wizard when creating a new Content entity within a group the page won't break but it will not be allowed to the Group.

Remaining tasks

Exception handling.

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

🐛 Bug report
Status

Active

Version

10.4

Component
Workspaces 

Last updated about 10 hours ago

No maintainer
Created by

🇮🇳India arunkumark Coimbatore

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

Merge Requests

Comments & Activities

  • Issue created by @arunkumark
  • 🇮🇳India arunkumark Coimbatore
  • 🇮🇳India arunkumark Coimbatore

    Temporary Solution:

    If you are keeping Use 2-step wizard when creating a new Content entity within a group the page won't break but it will not be allowed to the Group.

  • This issue is perhaps for the Group module rather than for Drupal Core.

  • 🇮🇳India arunkumark Coimbatore

    @cilefen
    Yes, the form Workspace support need to done from Group. But, page break should not happen. We have to handle the exception and solving the page break.

  • 🇷🇴Romania amateescu

    Throwing this exception is very much intentional, we need to warn developers that there's something to fix.

  • 🇮🇳India arunkumark Coimbatore

    Throwing this exception is very much intentional, we need to warn developers that there's something to fix.

    It was better to show an error in validation or show message rather than showing the page break.

  • heddn Nicaragua

    I'm going to remove the group.module's submit handler and use another that uses a cron queue instead.

  • heddn Nicaragua

    OK, that won't work. Instead I dove into seeing if we could actually support it. It would natively support it if relationships were revisionable. Since they aren't, see Support for Revisions of Group Relationship Entities Needs review , I think we should just mark the relationship entity as ignored. Working on MR.

  • heddn Nicaragua

    Here's a fairly minimal solution. Which should work in most cases.

  • Status changed to Needs review 3 months ago
  • Pipeline finished with Success
    3 months ago
    Total: 1094s
    #275108
  • heddn Nicaragua

    Feedback on MR addressed

  • Pipeline finished with Success
    3 months ago
    Total: 928s
    #275789
  • 🇮🇳India vinmayiswamy

    Hi,
I have tested the fix provided in MR !177. I followed the steps outlined in the issue summary to reproduce the issue before applying the fix and to verify the solution afterward.

    Before the fix, I encountered the White Screen of Death (WSOD) with the following error message:

    Drupal\Core\Entity\EntityStorageException: This entity can only be saved in the default workspace. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

    Although the node was created, it wasn’t added to the group, and the WSOD appeared with the above error logged.

    After applying the fix, the issue was resolved. The WSOD no longer occurred, and the node was successfully created and added to the group within the non-default workspace.

    Attaching before and after screenshots for reference.

    I believe this is now good to go for RTBC!

    Thanks!

  • Status changed to RTBC about 17 hours ago
  • heddn Nicaragua

    Based on #13, marking RTBC.

Production build 0.71.5 2024