GroupStatistics no field plugin_id in table group_content

Created on 22 November 2024, 2 days ago

Problem/Motivation

After updating to OS 12.4.6 groupStatistics.php causes an error:

Drupal\Core\Entity\Query\QueryException: 'plugin_id' not found in Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable() (Zeile 369 in /mnt/web/mafo/html/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).

#0 /mnt/web/mafo/html/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php(263): Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable('', 'plugin_id', 'INNER', NULL, 'base_table', 'id', Array)
#1 /mnt/web/mafo/html/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php(58): Drupal\Core\Entity\Query\Sql\Tables->addField('plugin_id', 'INNER', NULL)
#2 /mnt/web/mafo/html/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(176): Drupal\Core\Entity\Query\Sql\Condition->compile(Object(Drupal\mysql\Driver\Database\mysql\Select))
#3 /mnt/web/mafo/html/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(81): Drupal\Core\Entity\Query\Sql\Query->compile()
#4 /mnt/web/mafo/html/profiles/contrib/social/modules/social_features/social_group/src/GroupStatistics.php(89): Drupal\Core\Entity\Query\Sql\Query->execute()
#5 /mnt/web/mafo/html/profiles/contrib/social/modules/social_features/social_group/src/GroupStatistics.php(53): Drupal\social_group\GroupStatistics->count(Object(Drupal\social_group\Entity\Group), 'group_membershi...')

Proposed resolution

diff --git a/modules/social_features/social_features/social_group/src/GroupStatistics.php b/modules/social_features/social_features/social_group/src/GroupStatistics.php
index 746a7a9139..e72ccb75bd 100644
--- a/modules/social_features/social_features/social_group/src/GroupStatistics.php
+++ b/modules/social_features/social_features/social_group/src/GroupStatistics.php
@@ -50,7 +50,7 @@ public function __construct(Connection $connection, EntityTypeManagerInterface $
    *   The number of members.
    */
   public function getGroupMemberCount(GroupInterface $group) {
-    return $this->count($group, 'group_membership');
+    return $this->count($group, $group->getGroupType()->id() . '-group_membership');
   }

   /**
@@ -65,7 +65,7 @@ public function getGroupMemberCount(GroupInterface $group) {
    *   The number of nodes.
    */
   public function getGroupNodeCount(GroupInterface $group, $type) {
-    return $this->count($group, 'group_node:' . $type);
+    return $this->count($group, $group->getGroupType()->id() . '-' . 'group_node-' . $type);
   }

   /**
@@ -84,7 +84,7 @@ protected function count(GroupInterface $group, $type) {
     return $this->entityTypeManager->getStorage('group_content')->getQuery()
       ->accessCheck(FALSE)
       ->condition('gid', $group->id())
-      ->condition('plugin_id', $type)
+      ->condition('type', $type)
       ->count()
       ->execute();
   }
🐛 Bug report
Status

Active

Version

12.4

Component

Groups

Created by

🇩🇪Germany slowflyer

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

Comments & Activities

Production build 0.71.5 2024