Should upgrading a site from Group 1.0 to 2.0alpha4 be working at this point? If yes, then I hit a snag...

Problem/Motivation

Unable to upgrade a very simple Group site from 1.4 to 2.0alpha 4. Error occurs when running database updates.

$ drush updb
 -------- ----------- --------------- ----------------------------------------------------------------------------------- 
  Module   Update ID   Type            Description                                                                        
 -------- ----------- --------------- ----------------------------------------------------------------------------------- 
  group    9201        hook_update_n   9201 - Add plugin_id and group_type fields and update indexes for group content.   
  group    9202        hook_update_n   9202 - Remove the 'bypass group access' permission from all roles.                 
  group    9203        hook_update_n   9203 - Convert group roles with the 'administer group' permission to admin roles.  
  group    9204        hook_update_n   9204 - Convert synchronized group roles to new scope and target_role structure.    
  group    9205        hook_update_n   9205 - Convert default group roles to new scope and target_role structure.         
  group    9206        hook_update_n   9206 - Convert user created group roles to new scope and target_role structure.    
  group    9207        hook_update_n   9207 - Remove label and description from group content types.                      
 -------- ----------- --------------- ----------------------------------------------------------------------------------- 


 Do you wish to run the specified pending updates? (yes/no) [yes]:
 > 

>  [notice] Update started: group_update_9201
>  [error]  Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'plugin_id' cannot be null: INSERT INTO "tmp_8914b4group_content_field_data" ("id", "type", "langcode", "uid", "gid", "entity_id", "label", "created", "changed", "default_langcode", "plugin_id", "group_type") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11); Array
> (
>     [:db_insert_placeholder_0] => 1
>     [:db_insert_placeholder_1] => term-group_membership
>     [:db_insert_placeholder_2] => en
>     [:db_insert_placeholder_3] => 1
>     [:db_insert_placeholder_4] => 1
>     [:db_insert_placeholder_5] => 1
>     [:db_insert_placeholder_6] => admin
>     [:db_insert_placeholder_7] => 1654189793
>     [:db_insert_placeholder_8] => 1654189793
>     [:db_insert_placeholder_9] => 1
>     [:db_insert_placeholder_10] => 
>     [:db_insert_placeholder_11] => 
> )
>  in Drupal\mysql\Driver\Database\mysql\ExceptionHandler->handleExecutionException() (line 50 of /var/www/html/web/core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php). 
>  [error]  The entity update process failed while processing the entity type group_content, ID: 1. 
>  [error]  Update failed: group_update_9201 
 [error]  Update aborted by: group_update_9201 
 [error]  Finished performing updates. 
Failed to run drush updb: exit status 1 

Steps to reproduce

I was testing on my local with a very simple Group 1.4 site with a single group.

thank you!
-mike

Comments

ultimike created an issue. See original summary.

mxr576’s picture

kristiaanvandeneynde’s picture

Hmm, that shouldn't happen. An update hook should not be resaving entities. That's what post update hooks are for. If we can figure out why these entities are resaved, then we can avoid or fix this error.

But for now the upgrade path might not be fully functional yet, this should of course be working as soon as we go into beta.

kristiaanvandeneynde’s picture

We should be able to fix this by introducing GroupContentStorage::restore() just like we had to create GroupStorage::restore() a while back

kristiaanvandeneynde’s picture

Status: Active » Needs review
StatusFileSize
new1.67 KB

Try this.

kristiaanvandeneynde’s picture

Priority: Normal » Major

Also bumping priority as this is quite annoying for people trying out the new release.

ultimike’s picture

I found a few minutes today to do some initial testing of the patch in #5 above.

Initially, it didn't work due to (I believe) a missing use statement in the patch:

use Drupal\Core\Entity\EntityInterface;

Once I added that, things progressed a bit farther, but I ended up with the following error when running drush updb:

$ drush updb
 -------- ----------- --------------- ------------------------------------------------------------- 
  Module   Update ID   Type            Description                                                  
 -------- ----------- --------------- ------------------------------------------------------------- 
  group    9201        hook_update_n   9201 - Add plugin_id and group_type fields and update        
                                       indexes for group content.                                   
  group    9202        hook_update_n   9202 - Remove the 'bypass group access' permission from all  
                                       roles.                                                       
  group    9203        hook_update_n   9203 - Convert group roles with the 'administer group'       
                                       permission to admin roles.                                   
  group    9204        hook_update_n   9204 - Convert synchronized group roles to new scope and     
                                       target_role structure.                                       
  group    9205        hook_update_n   9205 - Convert default group roles to new scope and          
                                       target_role structure.                                       
  group    9206        hook_update_n   9206 - Convert user created group roles to new scope and     
                                       target_role structure.                                       
  group    9207        hook_update_n   9207 - Remove label and description from group content       
                                       types.                                                       
 -------- ----------- --------------- ------------------------------------------------------------- 


 Do you wish to run the specified pending updates? (yes/no) [yes]:
 > 

>  [notice] Update started: group_update_9201
>  [error]  Call to undefined method Drupal\group\Entity\GroupContent::getRelationshipType() 
>  [error]  Update failed: group_update_9201 
 [error]  Update aborted by: group_update_9201 
 [error]  Finished performing updates. 

I hope this is helpful.

Thanks, @kristiaanvandeneynde for your diligence on this issue!

-mike

kristiaanvandeneynde’s picture

StatusFileSize
new1.67 KB

Please make sure you're using the latest dev, though, as a lot of things got renamed in dev. Here's a reroll.

ultimike’s picture

Still no luck, unfortunately. Here's what I did:

1. I updated both Group and Flexible Permissions to their latest dev versions.

2. I tried to rebuild caches, but consistently received the error:

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86:
                                                                                                   
  The service "group_permission.calculator" has a dependency on a non-existent service "flexible_  
  permissions.chain_calculator"

Looking at flexible_permissions.services.yml, the "flexible_permissions.chain_calculator" is indeed listed.

3. I tried to run a database update, but it failed as well:

$ drush updb
 ---------- ---------------------- --------------- ------------------------------------------------ 
  Module     Update ID              Type            Description                                     
 ---------- ---------------------- --------------- ------------------------------------------------ 
  group      9201                   hook_update_n   9201 - Add plugin_id and group_type fields and  
                                                    update indexes for group_content.               
  group      9202                   hook_update_n   9202 - Remove the 'bypass group access'         
                                                    permission from all roles.                      
  group      9203                   hook_update_n   9203 - Convert group roles with the             
                                                    'administer group' permission to admin roles.   
  group      9204                   hook_update_n   9204 - Convert synchronized group roles to new  
                                                    scope and target_role structure.                
  group      9205                   hook_update_n   9205 - Convert default group roles to new       
                                                    scope and target_role structure.                
  group      9206                   hook_update_n   9206 - Convert user created group roles to new  
                                                    scope and target_role structure.                
  group      9207                   hook_update_n   9207 - Remove label and description from        
                                                    relationship types.                             
  group      9208                   hook_update_n   9208 - Introduce the group_config_wrapper       
                                                    entity type.                                                
 ---------- ---------------------- --------------- ------------------------------------------------ 


 Do you wish to run the specified pending updates? (yes/no) [yes]:
 > 

>  [notice] Update started: group_update_9201
>  [error]  The entity schema update for the group_content entity type requires a data migration. 
>  [error]  Update failed: group_update_9201 
 [error]  Update aborted by: group_update_9201 
 [error]  Finished performing updates. 

Thoughts?

-mike

kristiaanvandeneynde’s picture

I'm in the process of fixing this, I found that renaming the handlers and classes required an entity update to run. Doing so now and that might fix things.

kristiaanvandeneynde’s picture

Version: 2.0.0-alpha4 » 2.0.x-dev
StatusFileSize
new8.55 KB

This condenses the entity type updates and puts them at the very front of the list. I suppose it's okay to do this while in alpha.

ultimike’s picture

No luck - similar, but not exact issue.

1. drush cr leads to the

The service "group_permission.calculator" has a dependency on a non-existent service "flexible_  
  permissions.chain_calculator"

error.

2. drush updb leads to a new error:

>  [notice] Update started: group_update_9201
>  [error]  It is not possible to change the entity type schema outside of a batch context. Use EntityDefinitionUpdateManagerInterface::updateFieldableEntityType() instead. 
>  [error]  Update failed: group_update_9201 
 [error]  Update aborted by: group_update_9201 
 [error]  Finished performing updates. 

-mike

kristiaanvandeneynde’s picture

Hmm okay, will continue to work on this. Thanks for the review.

kristiaanvandeneynde’s picture

StatusFileSize
new7.19 KB

Okay so make sure you first install the new dependency: https://www.drupal.org/project/flexible_permissions

Then try this patch. I've just condensed everything into one update hook at the top, hopefully that makes it stop complaining about needing batch updates. It does on my end, but I'd love to see the same on your end :)

kristiaanvandeneynde’s picture

StatusFileSize
new7.19 KB

Sorry use this one instead.

kristiaanvandeneynde’s picture

StatusFileSize
new10.27 KB

Okay so here's what I did to get it to work:

  1. Install Group 1 and configure a few things
  2. Download and install Flexible Permissions
  3. Download Group 2
  4. Run updates
  5. Success!

Download and install FP before you update Group's code.

The latest patch circumvents a catch-22 with the old storage class gone missing yet somehow being required by Drupal for the updates.

ultimike’s picture

So far, so good. I was able to upgrade from 1.x to 2.x using the instructions in comment 16.

But, after I did so, I was looking at a list of nodes belonging to one of my groups (via /group/1/nodes) and there is something odd going on.

  • This group has two members - user IDs 1 and 3.
  • This group has three nodes - node IDs 1, 3, 4.
  • When I click to "View relation" for NID=3 (/group/1/content/3), I actually see the relation for UID=3, not NID=3.
  • When I click to "View relation" for NID=4 (/group/1/content/2), I actually see the relation for a node I had previously deleted.
  • When I click to "View relation" for NID=1 (/group/1/content/1), I actually see the relation for UID=1, not NID=1.
  • The "View member" links from /group/1/members appear to be working fine.
  • The "All entities" tab (/group/1/content) show 3 entities - UIDs 1 and 3 and NID=4, but not NIDs 1 nor 3.

It seems like something is getting confused with different entity types.

When I click "Add existing content" from /group/1/nodes, I get a blank page (the title and breadcrumbs are there, but no page content). Same for "Add new content".

Is this a bug with the upgrade path or something else?

-mike

ultimike’s picture

After further review, I think my comment #17 above was not correct, and therefore I'm pretty sure all is good.

I believe that originally, my group did not have 3 nodes, but only 1.

I was also confused that when I clicked on a node title on the "All entities" page (/group/1/content) I wasn't seeing the node, but rather the group relationship.

-mike

kristiaanvandeneynde’s picture

Status: Needs review » Fixed

Will tag a beta with this shortly.

Thanks for the feedback @ultimike!

fmb’s picture

StatusFileSize
new25.34 KB

With 2.0.0-beta1, I get this error in the status report, as well as messages containing "Table 'db.group_relationship_field_data' doesn't exist". Is this related to this issue? What should I do?

fmb’s picture

StatusFileSize
new1.26 KB

Apparently `drush updb` had returned no error.

When I try to force an entity update with the devel entity updates module (drush entup command), I get this message: "The entity schema update for the group_content entity type requires a data migration."

fmb’s picture

I ended up reinstalling the module.

fonant’s picture

Got it working, after trying to upgrade without enabling flexible_permissions first.

1. Downgrade group composer require 'drupal/group:^1.5' -W
2. Get flexible_permissions code composer require 'drupal/flexible_permissions:^1.0@beta'
3. Install (enable) flexible_permissions drush pm-enable flexible_permissions
4. Update group code composer require 'drupal/group:^2.0@beta'
5. Update database drush updatedb

kristiaanvandeneynde’s picture

Yeah that bit is important, it's at the top of the release notes for that reason :)

Status: Fixed » Closed (fixed)

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

rondog469’s picture

Am I wrong in thinking this modules composer.json require flexible permissions? I ran into this issue because I did not see the release notes from the first beta.

programmerdiego’s picture

Environment: Drupal v9.5.7, Groups Module v1.5.
I had two patches on my composer.json
1) (https://www.drupal.org/files/issues/group-content-entity-tokens-2916907-...)
2) https://www.drupal.org/files/issues/2022-02-09/group-fix-group-revisions...)

I removed both of my patches and ran the following and got my system to work.

1. Install Flexible Permissions: 'drupal/flexible_permissions:^1.0@beta'
2. Enabled Flexible Permissions: 'drush pm-enable flexible_permissions'
3. Update Group Module: 'composer require 'drupal/group:^2.0@beta'
4. Update database: 'lando drush updb'

pdcarto’s picture

Anybody reading all the way to the bottom of this issue thread may wonder why it's marked as "Fixed", when the last comment describes a bunch of manual steps. That's because those steps were added in the group.install file in 2.0.x: https://www.drupal.org/project/group/issues/3355034#comment-15075342