Problem/Motivation

Asking the entity type manager for a storage by name throws PluginNotFoundException when the module providing it is not installed, so every such call has to say what happens on a site that does not have it. Three of them do not, and none of the three modules is a dependency of this one.

  • menu_link_content, in the menu structure. Every item of a menu is looked up in that storage, including the items a module defines in its links.menu.yml file, which have no entity behind them at all: the metadata of such a link carries no entity_id key, so the code reads a missing array key and then asks a storage that need not exist. A site whose menus come from code and that never installed the module answers 500 for its own main menu.
  • block_content, in the block structure. The identifier comes in from the caller and is loaded from a storage that a site without the module does not have.
  • paragraph, in the resource that builds the static data of the front page. It creates a virtual paragraph to read a global block back through the field accessor; the module providing that entity type is a suggestion in composer.json, not a dependency.

The same question was asked of the whole module while fixing the characteristics field, and the rest of the calls were already right: the search index, the metatag entity and the characteristic values are all checked before they are asked for.

Proposed resolution

  • Check the entity type before asking for its storage in all three places, and answer with an empty structure the way a missing field reads as an empty value.
  • Read the link metadata for what it is: an item without an entity_id is a link defined in code, not an error, and it should keep its place in the menu with whatever the definition itself provides.
  • Cover the menu case with a kernel test - a menu of links defined in code, read on a site without the entity type - because it is the one of the three a site meets without doing anything unusual.

Remaining tasks

Everything.

Issue fork myrest-3619433

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

sergeydruua created an issue. See original summary.

  • sergeydruua committed a14e0f94 on 1.0.x
    Issue #3619433: Guard the three entity types of modules the module does...
sergeydruua’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

sergeydruua’s picture

Status: Fixed » Closed (fixed)