Problem/Motivation

Enabling a single media type seems to work well and allows creating media in a group via /group/1/media/create

Enabling multiple types of media on a group type causes errors, starting with this:

ArgumentCountError: Too few arguments to function Drupal\groupmedia\Controller\GroupMediaController::addPageBundles(), 2 passed in /app/web/modules/contrib/groupmedia/src/Controller/GroupMediaController.php on line 44 and exactly 3 expected in Drupal\groupmedia\Controller\GroupMediaController->addPageBundles() (line 72 of modules/contrib/groupmedia/src/Controller/GroupMediaController.php).

Steps to reproduce

  1. Install Group 3.0.0-beta4, Group Media 4.0.0-alpha-1, Drupal 9.4.8
  2. Create a group type
  3. Enable multiple content plugins, for example: Group media (Image) and Group media (Document)
  4. Create a group
  5. Go to /group/1/media/create
  6. See the above error.

Issue fork groupmedia-3325129

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

Finn Lewis created an issue. See original summary.

finn lewis’s picture

This line: https://git.drupalcode.org/project/groupmedia/-/blob/4.0.x/src/Controlle... does need another argument for addPageBundles, see https://git.drupalcode.org/project/groupmedia/-/blob/4.0.x/src/Controlle...

Adding that then gives:

TypeError: Illegal offset type in isset or empty in Drupal\groupmedia\Controller\GroupMediaController->addPage() (line 45 of modules/contrib/groupmedia/src/Controller/GroupMediaController.php).

Editing those lines to get the actual bundle name

    foreach ($this->addPageBundles($group, $create_mode, $base_plugin_id) as $plugin_id => $bundle) {
      $bundle_name = $bundle->getOriginalId();
      if (!empty($build['#bundles'][$bundle_name])) {

Then gives the following error:

Drupal\Component\Plugin\Exception\PluginNotFoundException: Plugin ID 'microsite-group_media-document' was not found. in Drupal\Core\Plugin\DefaultLazyPluginCollection->initializePlugin() (line 79 of core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php).

finn lewis’s picture

Status: Active » Needs review

Hi @LOBsTerr

I've created a merge request that fixes the issue for me.

Could you take a look and see if I've done it right?

Many thanks,

Finn

lobsterr’s picture

Assigned: Unassigned » lobsterr

  • 3dfac83 committed on 4.0.x
    Issue #3325129 by Finn Lewis, LOBsTerr: Too few arguments for...
lobsterr’s picture

Status: Needs review » Fixed

Thanks for your contribution

finn lewis’s picture

Thanks LOBsTerr! You're so on it! If we could get another tagged release.... that would be awesome!

  • LOBsTerr committed 997df7e on 3.0.x
    Issue #3325129: Fix media creation page with multiple bundles.
    
finn lewis’s picture

OMG - you're just too quick... thanks dude!

lobsterr’s picture

Heh, you are welcome

lobsterr’s picture

Status: Fixed » Needs work

I just realized it was a wrong approach. I will introduce a new changes soon

  • Finn Lewis committed 194f7bf on 4.0.x
    Update addPage to work with Group 3.x and suppress errors from #3325129
    
  • LOBsTerr committed 3fff820 on 4.0.x
    Issue #3325129: Refactor code.
    
  • LOBsTerr committed c9d30f6 on 4.0.x
    Issue #3325129: Merge reference.
    
  • LOBsTerr committed ceafb17 on 4.0.x
    Issue #3325129: Replace custom pages to add and to relate media items,...
lobsterr’s picture

Status: Needs work » Fixed
lobsterr’s picture

I have removed controller completely, because we don't need it anymore. We will use group default functionality.

Status: Fixed » Closed (fixed)

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