Problem/Motivation

The rector patch https://www.drupal.org/project/entitygroupfield/issues/3438342 is incomplete. It needs to remove variationcache references. Group does not need this any more, so there is no need for it. It is only used in the test file.

Proposed resolution

  • Expand the version constraints in .info.yml
  • Fix tests to work on D11, too
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

chris dart created an issue. See original summary.

chris dart’s picture

Status: Active » Needs review

I'm not sure why the pipeline is failing, but I believe this is ready for review. The changes appear to work correctly in a client's installation. So I may have made an error in the test file changes?

dylan donkersgoed’s picture

I've tested this in a relatively fresh Drupal install with groups and it seems to be working, at least in manual testing. I'm not moving it to RTBC for now because the automated tests seem to be failing. I'm not sure if that's actually cause for concern - they seem to fail in D10 before the changes from this issue as well, though with different errors.

My Drupal install was set up as follows *before* installing the entitygroupfield module::

  • Groups is installed
  • One group type, "test" is setup
  • The default basic page content type is installed in this group
  • Group permissions are configured such that anyone can view content in the group and members can add/edit basic pages and add basic pages to groups
  • There is a "test public group" group
  • There is a "test page in public group" basic page instance assigned to this group"

I tested the following as user 1:

  1. Adding the module via composer using a custom repo for this branch (added { "type": "vcs", "url": "git@git.drupal.org:issue/entitygroupfield-3515583.git" } to the repositories section of my composer.json, added "drupal/entitygroupfield": "dev-3515583-drupal-11-compatibility" to the require section, and then ran composer update)
  2. Installing the module
  3. Adding the basic page content type to groups
  4. Updating the basic page form display to show the entitygroupfield "Groups" field with widget "Group select" configured to be required
  5. Editing a node that already belonged to a group - the Groups field was populated as expected
  6. Adding a new node and assigning it to a group via the "Add new content" button on the group (as the group member) - it displays in the group admin interface as expected
  7. Edited this node, groups field is populated as expected
  8. Added same group member to another group
  9. Edited same node from before, group member was able to add additional groups as expected

D11 automated tests report the following failures:

There were 2 errors:

1) Drupal\Tests\entitygroupfield\Kernel\GroupAutocompleteFormElementTest::testGroupAutocompleteNoGroups
RuntimeException: Cannot compare markup between MarkupInterface objects and plain strings

/app/web/core/tests/Drupal/TestTools/Comparator/MarkupInterfaceComparator.php:42
/app/web/modules/contrib/entitygroupfield/tests/src/Kernel/GroupAutocompleteFormElementTest.php:110

2) Drupal\Tests\entitygroupfield\Kernel\GroupAutocompleteFormElementTest::testGroupAutocomplete
RuntimeException: Cannot compare markup between MarkupInterface objects and plain strings

/app/web/core/tests/Drupal/TestTools/Comparator/MarkupInterfaceComparator.php:42
/app/web/modules/contrib/entitygroupfield/tests/src/Kernel/GroupAutocompleteFormElementTest.php:163

ERRORS!
Tests: 4, Assertions: 140, Errors: 2, PHPUnit Deprecations: 9.

The CI failures seem to be because it's using PHP 7.4, which is not compatible with Drupal 11. Why that is I'm not sure, but I don't think it's related to the changes from this issue.

dylan donkersgoed’s picture

I pushed up a change to fix some issues causing the tests to fail due to some of the logic in the actual tests being deprecated: https://www.drupal.org/project/view_mode_switch/issues/3340835

They now fail in the same way as tests do in D10. I'm not sure if it's appropriate for me to mark this as RTBC since I've made changes to the tests, but FWIW I'm satisfied it's working for Drupal 11 with these changes based on my testing above and the automated test results now matching the D10 test results.

One of the tests, \Drupal\Tests\entitygroupfield\Kernel\GroupAutocompleteFormElementTest::testGroupAutcomplete is still failing with these errors, unrelated to the changes in the ticket:

Time: 00:23.350, Memory: 14.00 MB

There was 1 error:

1) Drupal\Tests\entitygroupfield\Kernel\GroupAutocompleteFormElementTest::testGroupAutocomplete
Drupal\Core\Entity\EntityStorageException: Could not assign role with ID ppd1fo48: Role belongs to a different group type.

/app/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:815
/app/web/modules/contrib/group/src/Entity/Group.php:147
/app/web/modules/contrib/group/src/Entity/Group.php:183
/app/web/modules/contrib/entitygroupfield/tests/src/Kernel/GroupAutocompleteFormElementTest.php:184

Caused by
Drupal\Core\Entity\EntityMalformedException: Could not assign role with ID ppd1fo48: Role belongs to a different group type.

/app/web/modules/contrib/group/src/Entity/GroupMembershipTrait.php:31
/app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:529
/app/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:760
/app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:484
/app/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:804
/app/web/modules/contrib/group/src/Entity/Group.php:147
/app/web/modules/contrib/group/src/Entity/Group.php:183
/app/web/modules/contrib/entitygroupfield/tests/src/Kernel/GroupAutocompleteFormElementTest.php:184

ERRORS!
Tests: 4, Assertions: 144, Errors: 1, PHPUnit Deprecations: 9.

dww’s picture

Version: 2.0.0-alpha1 » 2.0.x-dev
Status: Needs review » Needs work
Issue tags: +Needs reroll
Related issues: +#3401957: Fix GitLab-CI configuration on both 1.0.x and 2.0.x

Apologies for all the delays. I'm finally back to working on this project again. 😅

I fixed #3401957: Fix GitLab-CI configuration on both 1.0.x and 2.0.x so we've got green pipelines again. In the process, I fixed GroupAutocompleteFormElementTest to work with group *.3.x branches. See ee349a4f.

If we rebase the MR branch in the issue fork from the latest in 2.0.x branch, we should:

  1. Have working pipelines to start from
  2. Have an easy place to add D11-specific testing combinations to our GitLab CI matrix

After that, we can assess what else, if anything is needed in here.

I'm done for tonight, but I might work on this more over the weekend. Certainly early next week, if not.

Thanks!
-Derek

dww’s picture

p.s. To be clear, Group 4 support will only happen in the 2.1.x series, whenever that starts. This needs to focus on Group 3.3.x and 2.3.x support.

dww’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll

Rebased and started fixing up the MR. Let's see what the bot says.

dww’s picture

Sweet! Pipeline is now all green on all these combinations:
D11.2, G 3.3
D11.2, G 2.3
D10.5, G 3.3 (default config)
D10.5, G 3.2
D10.5, G 2.3
D9.5, G 3.2
D9.5, G 2.2

Huzzah! I think this is now ready to merge. Wouldn't mind if anyone else wants to do some mild testing or reviews.

Also, the summary here isn't really accurate. We do still need variationcache, but only conditionally on the older versions we still support.

Thanks,
-Derek

lambic’s picture

Reviewed the code, looks good to me.

  • dww committed 5d912b30 on 2.0.x
    task: [#3515583] Add Drupal 11 compatibility
    
    Co-authored-by: Derek...

dww’s picture

Issue summary: View changes
Status: Needs review » Fixed
Issue tags: -Needs issue summary update

Merged. Thanks, everyone!

My plan is to do some bug triage over the next few days, fix up a few more things, and tag another round of releases. Stay tuned.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

rbomhof’s picture

We were just looking at this one today as we move to D11, thank you!

dww’s picture

FYI: https://www.drupal.org/project/entitygroupfield/releases/2.0.0-rc1 is now out. Testing welcome. I'd like to put out the 2.0.0 stable release before the end of 2025, ideally before the end of November. 😅 Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.