getInstance() fatals on almost all plugin managers

Created on 30 November 2015, over 8 years ago
Updated 12 September 2023, 9 months ago

Problem/Motivation

PluginManagerBase:

  public function getInstance(array $options) {
    return $this->mapper->getInstance($options);
  }

Try drush ev '\Drupal::service("plugin.manager.action")->getInstance([])' and you will get

PHP Fatal error: Call to a member function getInstance() on null in /home/chx/www/d8/core/lib/Drupal/Component/Plugin/PluginManagerBase.php on line 97

By no means this is just the action manager. There are only 7 plugin managers overriding this, all the others will get this.

Proposed resolution

As a quick placebo, implement a MapperInterface class which throws an exception and set that as the default mapper in PluginManagerBase. That still leads to a fatal but it's less mysterious and more catchable.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

8.7 ⚰️

Component
PluginΒ  β†’

Last updated about 15 hours ago

Created by

πŸ‡¨πŸ‡¦Canada chx

Live updates comments and jobs are added and updated live.
  • DrupalWTF

    Worse Than Failure. Approximates the unpleasant remark made by Drupal developers when they first encounter a particular (mis)feature.

Sign in to follow issues

Comments & Activities

Not all content is available!

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

Production build 0.69.0 2024