- Issue created by @aleix
- πͺπΈSpain aleix
It was a faulty record in tables
group_content_field_data
andgroup_content_field_data
. Removing these entries makes updatedb fine.So I think this could be closed
- Status changed to Closed: works as designed
over 1 year ago 8:47pm 27 May 2023 - Status changed to Active
over 1 year ago 7:30am 26 July 2023 - π¦πΉAustria ViNCE
I'm facing the same problem.
[notice] Update started: group_update_9203 [error] Call to a member function getPluginId() on null [error] Update failed: group_update_9203
Already spent half a day and a night to try different ways. Already having several thousand entries in the database. Couldn't find a way to filter out faulty ones.
Any ideas how to either:- filter out and remove faulty entries?
- or change the update code in a way not ending up in a fatal error?
the actual code in group.install is:
function group_update_9203(&$sandbox) { $definition_update_manager = \Drupal::entityDefinitionUpdateManager(); $last_installed_schema_repository = \Drupal::service('entity.last_installed_schema.repository'); assert($last_installed_schema_repository instanceof EntityLastInstalledSchemaRepositoryInterface); // Update the database tables. $entity_type = $definition_update_manager->getEntityType('group_content'); $entity_type->set('base_table', 'group_relationship'); $entity_type->set('data_table', 'group_relationship_field_data'); // Add the plugin_id and group_type field. $field_storage_definitions = $last_installed_schema_repository->getLastInstalledFieldStorageDefinitions('group_content'); $field_storage_definitions['plugin_id'] = BaseFieldDefinition::create('string') ->setName('plugin_id') ->setTargetEntityTypeId('group_content') ->setTargetBundle(NULL) ->setLabel(t('Plugin ID')) ->setRequired(TRUE) ->setReadOnly(TRUE) ->setInitialValue('TEMP') ->setProvider('group'); $field_storage_definitions['group_type'] = BaseFieldDefinition::create('entity_reference') ->setName('group_type') ->setTargetEntityTypeId('group_content') ->setTargetBundle(NULL) ->setLabel(t('Group type')) ->setSetting('target_type', 'group_type') ->setRequired(TRUE) ->setReadOnly(TRUE) ->setInitialValue('TEMP') ->setProvider('group'); // Update the fields and regenerate indexes, the correct initial values will // be retrieved from GroupRelationshipStorage::restore(). $definition_update_manager->updateFieldableEntityType($entity_type, $field_storage_definitions, $sandbox); }
Hello @ViNCE,
I am facing an issue on the same hook. The error is "Langcode is missing". For me the field definition ($field_storage_definitions) is empty when I try to debug it in a preprocess. So obviously the Langcode field is missing for a translatable array.
I had tried to set these just before by using :
$storage_definitions = $entityFieldManager->getFieldStorageDefinitions('group_content'); $last_installed_schema_repository->setLastInstalledFieldStorageDefinitions('group_content',$storage_definitions);
And then it shows me other errors.
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'entity_id' cannot be null: INSERT INTO "tmp_4e14aegroup_relationship_field_data"
it seems that it has loop over some database entries because there is some warning that are repeated before :
[warning] Undefined array key "plugin_id" SqlContentEntityStorage.php:597 [warning] Undefined array key "group_type" SqlContentEntityStorage.php:597
Il your storage definition empty ?
Does the hook seems to process some items and one is failing or it fails at the beginning ?Hi,
I use res-ben code β¨ Entities identified by strings as group content Closed: won't fix to properly uninstall patch "2797793-279.patch".
This code populates 'entity_id' column during the process.- πΊπΈUnited States Flotsam
@aleix - I realize your comment at #3 is five months old, but do you recall how you identified the 'faulty records' in tables
group_content_field_data
andgroup_content
that needed removing? - πͺπΈSpain aleix
Cannot recall exactly, but looking the tables I think that it was some non existing entity somewhere indexed in this table, If you have not too much entries check these id's. Or better use dpm or xdebug breakpoint to check which id is failing...
- πΊπΈUnited States Flotsam
Many thanks @aleix - it turned out we had left behind some rows in the group_content table that referenced items that were (at one point) found in the group_content__entity_id_str table to support the essentially defunct groupmenu module. We removed references to those items in both group_content_field_data and group_content tables and we stopped having this issue. (We have moved away from groupmenu and are adopting group_content_menu - but getting out from under the patch from https://www.drupal.org/project/group/issues/2797793 β¨ Entities identified by strings as group content Closed: won't fix was a bear.)
It turned out we also had left behind some rows in the following database tables
- group_content
- group_content_field_data
I ran some comparisons using the YML file to determine which rows I need to delete. The YML files for these content types have names like group.content_type.group_content_type_1123kl123lkzz.yml
If you have orphaned data you might find out which type or bundle rows need to be deleted based on the group content type config files you have.
Once you have determined the orphaned rows, you can run some database delete queries.
\Drupal::database()->delete('group_content') ->condition('type', 'group_content_type_1123kl123lkzz', '=') ->execute(); \Drupal::database()->delete('group_content_field_data') ->condition('type', 'group_content_type_1123kl123lkzz', '=') ->execute();
- π§πͺBelgium xdequinze Brussels
After removing orphaned types in group_content and group_content_field_data tables, updating the database by
> drush updatedb
results in
> [notice] Update started: group_update_9200
> [notice] Update completed: group_update_9200
> [notice] Update started: group_update_9201
> [notice] Update completed: group_update_9201
> [notice] Update started: group_update_9202
> [notice] Update completed: group_update_9202
> [notice] Update started: group_update_9203
> [error] 'plugin_id' not found
> [error] Update failed: group_update_9203
[error] Update aborted by: group_update_9203
[error] Finished performing updates.or by /update.php
Update #9203
Failed: Drupal\Core\Entity\Query\QueryException: 'plugin_id' not found in Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable() (line 369 of /home/xd/Docks/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).
- πΊπΈUnited States RichardDavies Portland, Oregon
I recently went through this same issue with a Group 1 -> 2 upgrade. As others have already mentioned, the error was caused by orphaned records in the
group_content
andgroup_content_field_data
tables. For those looking for more details about how to identify such orphaned records, here are two SQL queries that worked to clean up our orphaned records:delete from group_content_field_data where id in ( select gcfd.id from group_content_field_data gcfd left join groups on gcfd.gid = groups.id where groups.id is NULL ); delete from group_content where id in ( select gc.id from group_content gc left join group_content_field_data gcfd on gc.id = gcfd.id where gcfd.id is NULL );
The first query deletes orphaned records from group_content_field_data that are assigned to a group that no longer exists. The second query deletes orphaned records from group_content that don't have a corresponding record in group_content_field_data (either because the field_data record was just removed by the first query or due to some other previous data corruption issue).
If that doesn't resolve it, I would look for records in both tables whose field
type
value is invalid. The type value should correspond to one of your group content plugins' machine name/ID defined at/admin/group/types/manage/[group_type]/content
. (Hover over the Configure button and look at the URL to see the machine name/ID.)