public function getFieldStorageDefinitions() {
    $definitions = [];
    foreach (array_keys($this->pluginManager->getDefinitions()) as $plugin_id) {
      /** @var \Drupal\entity\BundlePlugin\BundlePluginInterface $plugin */
      $plugin = $this->pluginManager->createInstance($plugin_id);

There's no code that enforces that the plugin object actually implements BundlePluginInterface.

It would be good DX to add a check that $plugin instanceof BundlePluginInterface and throw an exception if not, so that a developer who's not added the interface gets a clear message about.

getFieldStorageDefinitions() is called only on rebuild, so it's not a performance cost.

CommentFileSizeAuthor
#3 3057208-3-bundle-plugin-assert.patch1.32 KBbojanz

Comments

joachim created an issue. See original summary.

bojanz’s picture

Title: check that bundle plugins implement the interface » BundlePluginHandler should assert that plugins implement BundlePluginInterface

Better title.

Core (and Commerce with the InlineForm API) usually does this via assertions.

bojanz’s picture

Status: Active » Needs review
StatusFileSize
new1.32 KB

  • bojanz committed 79694ad on 8.x-1.x
    Issue #3057208 by bojanz, joachim: BundlePluginHandler should assert...
bojanz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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