Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 296326

Context values passed in configuration to ContextAwarePluginBase are disregarded

$
0
0

Problem/Motivation

It is supposed to be possible to pass context values into plugins that extend ContextAwarePluginBase, as part of their configuration. However, it isn't, because of this line:

    $this->contexts = $this->context = $this->createContextFromConfiguration($context_configuration);

The actual property that stores contexts, and is used by many other methods of ContextAwarePluginBase, is $context, not $contexts. So what this line is actually doing, is setting a new, dynamic public property with all the context values (which is potentially very dangerous), while ensuring that the context values given in the plugin configuration are completely ignored (which can result in exceptions).

Proposed resolution

That line should set the value of $this->context, not $this->contexts.

Remaining tasks

Write a patch with a failing test, and fix it. We will probably also need a BC layer, which means adding a deprecated, private $contexts property to ContextAwarePluginBase, with a magic __get() method that throws a deprecation notice if something tries to access it.

User interface changes

None.

API changes

Plugins that extend ContextAwarePluginBase will now be able to accept context values in their configuration (as was the original intention); the dynamic $contexts property will be deprecated.

Data model changes

None.

Release notes snippet

TBD


Viewing all articles
Browse latest Browse all 296326

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>