More contexts needed

Created on 10 October 2016, about 8 years ago
Updated 23 January 2023, almost 2 years ago

So far the group module provides one context service, GroupRouteContext, which takes the context from the path.
The views groupPermission handler ONLY takes its context from the path.
However I would like contexts of:
- all the groups the current user is in (perhaps filtered by group type)
- all the groups the current content is in.
Does it make sense for contexts to return several groups?

📌 Task
Status

Needs work

Version

3.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇮Finland thatguy

    Re-rolled patch from #40 to work with dev-3.0.x version

  • 🇺🇸United States kroh San Antonio, TX

    Re-rolled patch from #40 to work with 2.0.x

  • 🇨🇦Canada gwvoigt London, ON 🇨🇦

    Thanks, patch from #41 working on 3.x for me

  • 🇺🇸United States scotwith1t Birmingham, AL

    Patch needs a re-roll for new 3.0.0 release.

  • 🇺🇸United States scotwith1t Birmingham, AL

    Taking a stab...this is NOT my strong point, apologies if this is all messed up.

  • 🇨🇭Switzerland phma Basel, CH

    Re-roll of #44 for 2.1.x

  • 🇨🇭Switzerland phma Basel, CH
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    9,623 pass, 1 fail
  • 🇬🇧United Kingdom billywardrop

    I patched groups 3.1 using the patch file in comment #46 but this stopped my theme running due to an error stating that group_content entity doesn't exist. Groups 3 now uses the group_relationship entity so I changed the entity type to group_relationship and the group nodes now show group blocks.

    I have create a new patch and interdiff for this.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    9,623 pass, 1 fail
  • 🇺🇦Ukraine ruslan piskarov Kyiv, Ukraine

    Improved #48. Just removed "+ + " in diff.

  • heddn Nicaragua
    +++ b/src/Context/GroupRouteContextTrait.php
    @@ -81,4 +84,36 @@ trait GroupRouteContextTrait {
    +      return $parameter instanceof NodeInterface;
    

    Why are we focused on Nodes? Why not just entity interface instead? then it will work for anything that group itself supports.

  • Reroll #49 for 2.2.x — for people on the upgrade path. My first patch, sorry if I messed it up.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    9,624 pass, 1 fail
  • 🇺🇸United States banoodle San Francisco, CA

    Patch #51 applied OK for me, but throws these errors due to the inclusion of group_content.

    Drupal\Component\Plugin\Exception\PluginNotFoundException: The "group_content" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of /code/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php).

    This patch I'm uploading just replaces "group_content" with "group_relationship".

  • 🇦🇲Armenia le72 Yerevan 🇦🇲

    What is the state of Group v3 patch?
    I did fresh Drupal 10 install with Layout builder and Group 3. The problem 35 is still there.

  • First commit to issue fork.
  • Merge request !158Patch #52 → (Open) created by karlshea
  • Merge request !159Patch #49 → (Open) created by karlshea
  • 🇺🇸United States karlshea Minneapolis 🇺🇸

    Created MRs for both 3.x and 2.x from the latest patches.

  • Pipeline finished with Canceled
    7 months ago
    Total: 253s
    #165782
  • Pipeline finished with Failed
    7 months ago
    Total: 907s
    #165789
  • 🇺🇸United States dasginganinja Bethlehem, PA

    @KarlShea, thanks for opening those MRs!

    I used !159 and it worked ONLY AFTER I added the following line at the top of `src/Access/GroupPermissionAccessCheck.php`:

    use Drupal\group\Context\GroupRouteContext;
    

    After this patch was in place existing usages of the context_provider now started matching nodes associated with groups to their associated group.

    Please note we only allow a group cardinality of one in our case.

    Thank you and please add that to your MRs!

  • 🇺🇸United States dasginganinja Bethlehem, PA

    Updating target for 3.3.x-dev

  • 🇩🇪Germany geek-merlin Freiburg, Germany

    Feedback: We used patch #52 in a project, but it broke access for links because the access check code is wrong (must not use current context as access can also be checked via $url->access().
    Did not investigate further, will do it differently.

  • First commit to issue fork.
  • 🇨🇦Canada slydevil Halifax

    Added to the 2.2.2 MR, so the GroupRouteContext takes into account situations where the 'group' Route parameter is an ID rather than a fully loaded Group entity. This happens when you use permissions rather than group permissions (as far as I can tell).

    Patch attached as well.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 322s
    #327177
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 1120s
    #327180
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 457s
    #327196
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 820s
    #327202
  • Pipeline finished with Canceled
    about 1 month ago
    Total: 520s
    #327208
  • Pipeline finished with Success
    about 1 month ago
    Total: 1145s
    #327212
  • Status changed to Needs review about 1 month ago
  • 🇺🇸United States karlshea Minneapolis 🇺🇸

    Rebased on 2.3.0/3.3.0, fixed phpcs/phpstan issues.

  • Pipeline finished with Success
    about 1 month ago
    Total: 1756s
    #327253
  • 🇷🇺Russia ScorpionGhost

    All patches stopped applying after updating the group to version 3.3.0

  • 🇩🇪Germany markdc Hamburg

    Same for 2.3.0

  • 🇺🇸United States karlshea Minneapolis 🇺🇸

    Yes, that's why I rebased the MRs.

  • 🇩🇪Germany markdc Hamburg

    Apologies. I forgot that a MR is also usable as a patch.

    !59 is working for me. Thank you!

  • 🇩🇪Germany markdc Hamburg

    Maybe I spoke too soon. The patch applied, but I get the following WSOD on Views that use the Group ID context. I also get this error in the console when trying to add the context to a new View:

    Drupal\Component\Plugin\Exception\PluginNotFoundException: The "group_relationship" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 142 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).
    Drupal\Core\Entity\EntityTypeManager->getHandler() (Line: 195)
    Drupal\Core\Entity\EntityTypeManager->getStorage() (Line: 113)
    Drupal\group\Context\GroupRouteContext->getBestCandidate() (Line: 52)
    Drupal\group\Context\GroupRouteContext->getRuntimeContexts() (Line: 71)
    Drupal\Core\Plugin\Context\LazyContextRepository->getRuntimeContexts() (Line: 91)
    Drupal\block\BlockAccessControlHandler->checkAccess() (Line: 109)
    Drupal\Core\Entity\EntityAccessControlHandler->access() (Line: 329)
    Drupal\Core\Entity\EntityBase->access() (Line: 63)
    Drupal\block\BlockRepository->getVisibleBlocksPerRegion() (Line: 138)
    Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 270)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
    call_user_func() (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 263)
    Drupal\shield\ShieldMiddleware->bypass() (Line: 219)
    Drupal\shield\ShieldMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
Production build 0.71.5 2024