An int passed into constructor as pluginDefinition value

Created on 3 May 2022, about 2 years ago
Updated 2 September 2023, 10 months ago

Problem/Motivation

See in watchdog: Notice: Trying to access array offset on value of type int in Drupal\shortcode\Plugin\ShortcodeBase->__construct() (line 57 of /var/www/xxx/web/modules/contrib/shortcode/src/Plugin/ShortcodeBase.php)

Looking at line 57, The pluginDefinition in the constructor has an int, value of 0, being passed in instead of an array.

Note: Shortcode Basic Tags is disabled
But nd_visualshortcodes, jango_shortcodes enabled

Steps to reproduce

Edit (some?) content which have shortcode enabled

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom Jons

Live updates comments and jobs are added and updated live.
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.

  • 🇬🇷Greece perarg

    Based on Jons comment #2, I created a patch. I think that the code needs a small fix so I've done it, too.

    if (!empty($plugin_definition)) {
        $this->provider = $this->pluginDefinition['provider'];
    }
    if (!empty($configuration)) {
        $this->setConfiguration($configuration);
    }
  • 🇬🇷Greece perarg

    ...and the correct patch is this (sorry for that mess)

  • 🇬🇧United Kingdom Jons

    thanks

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Plugin instances are not created by directly calling the constructor of the plugin class. If a module does that, that is a bug in that module, not in this module.

    None of the classes that extends PluginBase verifies $this->pluginDefinition is not empty because plugins always have a plugin definition.

Production build 0.69.0 2024