Skip to content
Snippets Groups Projects
Unverified Commit 390e3e00 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3240909 by andypost, alexpott, tim.plunkett: Plugin definitions with no...

Issue #3240909 by andypost, alexpott, tim.plunkett: Plugin definitions with no class trigger deprecations on PHP 8.1
parent 241acb9c
No related branches found
No related tags found
12 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1896Issue #2940605: Can only intentionally re-render an entity with references 20 times,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!512Issue #3207771: Menu UI node type form documentation points to non-existent function,!485Sets the autocomplete attribute for username/password input field on login form.,!449Issue #2784233: Allow multiple vocabularies in the taxonomy filter,!231Issue #2671162: summary text wysiwyg patch working fine on 9.2.0-dev,!30Issue #3182188: Updates composer usage to point at ./vendor/bin/composer
......@@ -246,6 +246,7 @@ public function processDefinition(&$definition, $plugin_id) {
// Keep class definitions standard with no leading slash.
if ($definition instanceof PluginDefinitionInterface) {
assert(is_string($definition->getClass()), 'Plugin definitions must have a class');
$definition->setClass(ltrim($definition->getClass(), '\\'));
}
elseif (is_array($definition) && isset($definition['class'])) {
......
......@@ -126,10 +126,10 @@ public function testLoadNull() {
*/
public function testFindDefinitions() {
$this->discovery->getDefinitions()->willReturn([
'plugin1' => new SectionStorageDefinition(),
'plugin2' => new SectionStorageDefinition(['weight' => -5]),
'plugin3' => new SectionStorageDefinition(['weight' => -5]),
'plugin4' => new SectionStorageDefinition(['weight' => 10]),
'plugin1' => (new SectionStorageDefinition())->setClass(SectionStorageInterface::class),
'plugin2' => (new SectionStorageDefinition(['weight' => -5]))->setClass(SectionStorageInterface::class),
'plugin3' => (new SectionStorageDefinition(['weight' => -5]))->setClass(SectionStorageInterface::class),
'plugin4' => (new SectionStorageDefinition(['weight' => 10]))->setClass(SectionStorageInterface::class),
]);
$expected = [
......@@ -156,9 +156,9 @@ public function testFindByContext($plugin_is_applicable) {
'foo' => new Context(new ContextDefinition('foo')),
];
$definitions = [
'no_access' => new SectionStorageDefinition(),
'missing_contexts' => new SectionStorageDefinition(),
'provider_access' => new SectionStorageDefinition(),
'no_access' => (new SectionStorageDefinition())->setClass(SectionStorageInterface::class),
'missing_contexts' => (new SectionStorageDefinition())->setClass(SectionStorageInterface::class),
'provider_access' => (new SectionStorageDefinition())->setClass(SectionStorageInterface::class),
];
$this->discovery->getDefinitions()->willReturn($definitions);
......@@ -211,8 +211,8 @@ public function testFindByContextCacheableSectionStorage() {
];
$definitions = [
'first' => new SectionStorageDefinition(),
'second' => new SectionStorageDefinition(),
'first' => (new SectionStorageDefinition())->setClass(SectionStorageInterface::class),
'second' => (new SectionStorageDefinition())->setClass(SectionStorageInterface::class),
];
$this->discovery->getDefinitions()->willReturn($definitions);
......
......@@ -11,6 +11,7 @@
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Layout\LayoutDefinition;
use Drupal\Core\Layout\LayoutInterface;
use Drupal\Core\Layout\LayoutPluginManager;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Tests\UnitTestCase;
......@@ -404,6 +405,7 @@ public function getDerivativeDefinitions($base_plugin_definition) {
'id' => 'invalid_provider',
'provider' => 'invalid_provider',
]);
$this->derivatives['invalid_provider']->setClass(LayoutInterface::class);
}
return $this->derivatives;
}
......
......@@ -511,6 +511,8 @@ class ObjectDefinition extends PluginDefinition {
* @param array $definition
*/
public function __construct(array $definition) {
// This class does not exist but plugin definitions must provide a class.
$this->class = 'PluginObject';
foreach ($definition as $property => $value) {
$this->{$property} = $value;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment