Module installation fails under some conditions

Created on 6 November 2023, 8 months ago
Updated 1 December 2023, 7 months ago

Problem/Motivation

While trying to install Ableplayer there are some conditions under which it can fail during ableplayer_install(). Error thrown is as follows:

Error: Call to a member function getHighestWeight() on null in ableplayer_install() (line 43 of /path/to/app/modules/contrib/ableplayer/ableplayer.install).

It appears to be happening here: https://git.drupalcode.org/project/ableplayer/-/blob/3.x/ableplayer.inst...

Seems to be happening when there's no entity form for a given media type. Not sure what might cause this yet, but we need to keep the installer running so it doesn't break.

Steps to reproduce

  1. Set up media types
  2. Install Ableplayer

Proposed resolution

Skip media types that don't have an entity form.

Remaining tasks

  1. Patch ableplayer.install

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia geoffreyr

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

Merge Requests

Comments & Activities

  • Issue created by @geoffreyr
  • Status changed to Needs review 8 months ago
  • πŸ‡¦πŸ‡ΊAustralia geoffreyr

    Added a MR for branch 3399722-module-installation-fails. This adds checks for the various forms during the installer and logs a warning when they're not found.

    Unfortunately this doesn't get to the root cause of why a media type might not have that form; I need to do some more investigation. However, I hope this might help someone else with the same problem.

  • πŸ‡ΊπŸ‡ΈUnited States theMusician

    Thank you. We'll review this soon. I appreciate the report and an idea of at least helping work around the issue while we figure out why.

    I think the standard profile includes media but if another profile is used it would be possible for media not to be enabled. I have also seen sites that were not D9 originally, so those upgraded from prior versions where media types are not necessarily named the same because one had to create them manually in the past. This is especially true for local video types.

  • πŸ‡ΊπŸ‡ΈUnited States theMusician

    @geofferyr can you outline in more detail how you found and replicated this error? I did a fresh install, and deleted the local and video media types. I deleted their entity form configs via drush and the installs still worked with your code, but no error message was ever logged. I tried it with just one media type deleted and then deleting the config and it was reinstalled upon enabling able player.

    Thank you

  • πŸ‡¦πŸ‡ΊAustralia geoffreyr

    @theMusician We already had an extensive code and config base for the site we were adding Ableplayer to, so this will probably be hard to replicate. Thanks for testing the patch out, it is odd that nothing got logged even when you specifically removed the form displays. I'll see if I can find time to put together an example.

  • πŸ‡¦πŸ‡ΊAustralia geoffreyr

    Digging deeper into this. I'm seeing the following fired off during an install of the Ableplayer module.

    $form = \Drupal::entityTypeManager()->getStorage('entity_form_display')->load('media.' . $bundle->get('id') . '.default');

    Causes the exception Missing required properties for an EntityDisplay entity. to be thrown. The contents of the values it is sent are as follows:

    Array (
      [content] => Array
      (
        [field_ableplayer_media_caption] => Array
        (
          [type] => media_library_widget
        )
      )
    )

    EntityDisplayBase expects a targetEntityType and bundle property to be present as well. But I'm not sure where it's supposed to be coming from; and this is during a load method call to boot. It's not cached the old config, and ableplayer's formatter isn't even present in the config table. Very odd.

  • πŸ‡ΊπŸ‡ΈUnited States theMusician

    Thank you for the additional information. I have seen inconsistent behavior on sites built prior to 8 including media. Your note about the install profile makes me think you discovered what was causing that.

    Most of the config is stored in the optional directory so maybe since it is looking at a prior installed site the config is not being pulled in? It should on the first and subsequent installs of the module but it seems like it is being skipped from your digging.

    Able player media caption is distinct in case sites are doing translation, it lets you load the caption files in many languages.

    I think the patch is a good path forward, especially if this is an edge case, if it is. With your patch, after install does everything work properly once you create the form?

  • Status changed to Fixed 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States theMusician

    Thank you for the work on this issue.

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

Production build 0.69.0 2024