Updated as of #70

Problem/Motivation

Most, if not all derivers do not set plugin IDs for derivative definitions explicitly, but provide it by merging in the base plugin definition for defaults. This means that for any derivative definition, the specified ID is that of the base plugin, even though the keys in the definitions array are correct (see #2458723: Incomplete documentation for DiscoveryInterface::getDefinitions()).

\Drupal\system\Plugin\Derivative\SystemMenuBlock is a concise example:

  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->menuStorage->loadMultiple() as $menu => $entity) {
      $this->derivatives[$menu] = $base_plugin_definition;
      $this->derivatives[$menu]['admin_label'] = $entity->label();
      $this->derivatives[$menu]['config_dependencies']['config'] = [$entity->getConfigDependencyName()];
    }
    return $this->derivatives;
  }

In the above example the derivative ID will be $menue main and for derivatives will be of the form $base_plugin_id:$derivative_id system_menu_block:main, but for derivatives, the $definition item contains only the $base_plugin_id system_menu_block, so that multiple $definition values will have the same ID in them.

Proposed resolution

Merge in the derivative ID in \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator.

Remaining tasks

Find a way to set the derivative ID.

User interface changes

None.

API changes

None.

CommentFileSizeAuthor
#109 2458769-nr-bot.txt149 bytesneeds-review-queue-bot
#98 2458769-98.patch12.17 KBdhirendra.mishra
#95 interdiff_93-95.txt1.18 KBvsujeetkumar
#95 2458769-95.patch12.1 KBvsujeetkumar
#93 interdiff_91-93.txt1.05 KBvsujeetkumar
#93 2458769-93.patch10.73 KBvsujeetkumar
#91 interdiff_89-91.txt947 bytesvsujeetkumar
#91 2458769-91.patch11.1 KBvsujeetkumar
#89 2458769-89.patch10.65 KBquietone
#89 diff-85-89.txt1.28 KBquietone
#85 2458769-82.patch10.71 KBquietone
#85 interdiff-82-85.txt829 bytesquietone
#82 2458769-82.patch10.71 KBquietone
#82 interdiff-80-82.txt8.88 KBquietone
#80 2458769-80.patch11.08 KBquietone
#80 interdiff-77-80.txt2.84 KBquietone
#77 2458769-77.patch11.15 KBquietone
#77 interdiff-75-77.txt1.11 KBquietone
#75 2458769-75.patch10.84 KBquietone
#75 interdiff-73-75.txt455 bytesquietone
#73 2458769-73.patch10.29 KBquietone
#73 interdiff-71-73.txt4.23 KBquietone
#71 2458769-71.patch15.05 KBquietone
#71 diff-39-71.txt20.63 KBquietone
#65 2458769-64.patch12.28 KBjpatel657
#62 2458769-62.patch11.65 KBdeepakaryan1988
#60 2458769-60.patch11.87 KBdeepakaryan1988
#57 2458769-57.patch12.25 KBjofitz
#55 2458769-55.patch8.53 KBhardik_patel_12
#53 2458769-53.patch12.04 KBswatichouhan012
#39 drupal_2458769_39.patch21.14 KBxano
#39 interdiff.txt2.46 KBxano
#35 drupal_2458769_34.patch21.38 KBxano
#35 interdiff.txt9.51 KBxano
#30 drupal_2458769_30.patch12.6 KBxano
#25 drupal_2458769_25.patch12.6 KBxano
#21 drupal_2458769_21.patch11.71 KBxano
#21 interdiff.txt912 bytesxano
#19 drupal_2458769_19.patch10.82 KBxano
#19 interdiff.txt1.1 KBxano
#16 drupal_2458769_16.patch10.25 KBxano
#6 drupal_2458769_6.patch4.48 KBxano
#6 interdiff.txt1.33 KBxano
#3 drupal_2458769_3.patch4.18 KBxano

Issue fork drupal-2458769

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

xano’s picture

Before we can fix this, we need to make a fundamental decision about what to do with plugin code that applies to both object and array plugin definitions. Seeing as object definitions are custom and we are in beta, I propose all code is standardized for array definitions. Child classes are then used to support object definitions.

xano’s picture

xano’s picture

Status: Active » Needs review
StatusFileSize
new4.18 KB
xano’s picture

I removed the object definition test, because they are simply not supported. The test was faulty anyway, as the definition merge only supports arrays.

berdir’s picture

+++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
@@ -73,6 +73,7 @@ public function getDefinition($plugin_id, $exception_on_invalid = TRUE) {
         }
+        $plugin_definition['id'] = $plugin_id;
       }
     }
 
@@ -110,6 +111,7 @@ protected function getDerivatives(array $base_plugin_definitions) {

@@ -110,6 +111,7 @@ protected function getDerivatives(array $base_plugin_definitions) {
           if ($derivative_id && isset($base_plugin_definitions[$plugin_id])) {
             $derivative_definition = $this->mergeDerivativeDefinition($base_plugin_definitions[$plugin_id], $derivative_definition);
           }
+          $derivative_definition['id'] = $plugin_id;
           $plugin_definitions[$plugin_id] = $derivative_definition;

Should we add a short comment here, something like '// Ensure that the plugin id is set to the derivative plugin id'?

xano’s picture

StatusFileSize
new1.33 KB
new4.48 KB
xano’s picture

Status: Needs work » Postponed

We're encountering more and more issues that are caused by the fundamental problem of having multiple definition types. Multiple workarounds have bee suggested and they all greatly reduce DX and maintainability. Let's fix this once and for all in #2458789: Introduce PluginDefinitionInterface.

xano’s picture

We may fix this in #2458789: Introduce PluginDefinitionInterface, as this bug is causing test errors there.

xano’s picture

#2458789: Introduce PluginDefinitionInterface now passes all tests and is ready for manual review. The patches there contain the fix for the bug this issue is about, because it caused test failures there.

fabianx’s picture

Tagging for framework manager review as #2458789: Introduce PluginDefinitionInterface was pushed back.

xano’s picture

Status: Postponed » Active

Bump.

jibran’s picture

Status: Active » Needs work
Issue tags: -Needs framework manager review +Needs reroll

#2458789: Introduce PluginDefinitionInterface is postponed to 9.x so no need for framework manager review. Let's fix it without #2458789: Introduce PluginDefinitionInterface.

xano’s picture

Issue tags: -Needs reroll

#2485513: DefaultFactory cannot deal with objects as plugin definitions introduces the most minimal PluginDefinitionInterface possible. When that's committed, we can extend the interface with ::setId() and ::getId() to fix this issue in the same way as we fixed the bug in the other issue.

This also requires a completely new patch, so removing the needs reroll tag.

xano’s picture

StatusFileSize
new10.25 KB

This is a first stab at fixing the problem using the new interface. This patch depends on the one from #2485513: DefaultFactory cannot deal with objects as plugin definitions and will not apply without it.

This patch introduces two new interfaces: one for merging plugin definitions, and one for plugin definitions to define derivers. No implementations of these interfaces exist.
It also extends #2485513: DefaultFactory cannot deal with objects as plugin definitions's PluginDefinitionInterface with methods for plugin IDs, which really cannot live in any optional interface.
The newly introduced methods and interfaces are then used by DefaultFactory to be able to deal with both array and object plugin definitions.

xano’s picture

Status: Needs work » Needs review
xano’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB
new10.82 KB
xano’s picture

Status: Needs work » Needs review
StatusFileSize
new912 bytes
new11.71 KB
xano’s picture

I am not able to reproduce all of the remaining test failures locally. Is someone else?

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new12.6 KB

This removes the BC breaks.

xano’s picture

Issue tags: +classed plugin definitions

Since all our code that handles array-based plugin definitions assumes every definition contains an id key, we could argue object definitions must provide IDs as well, and that we should break BC by adding methods to \Drupal\Component\Plugin\Definition\PluginDefinitionInterface. If we do not expand this interface, we end up with methods that are simple for arrays (because those assume easy array access with required keys), and with several lines of type checks for classed definitions.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xano’s picture

Bump. This issue could use feedback from other contributors.

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new12.6 KB

Re-roll.

The new \Drupal\Component\Plugin\Definition\MergeablePluginDefinitionInterface does conflict with \Drupal\plugin\PluginDefinition\PluginDefinitionInterface, unfortunately.

xano’s picture

Version: 8.1.x-dev » 8.2.x-dev
xano’s picture

Status: Needs work » Needs review
StatusFileSize
new9.51 KB
new21.38 KB

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

berdir’s picture

Status: Needs review » Needs work
  1. +++ b/core/lib/Drupal/Component/Plugin/Definition/MergeablePluginDefinitionInterface.php
    @@ -0,0 +1,39 @@
    +/**
    + * @file
    + * Contains \Drupal\Component\Plugin\Definition\MergeablePluginDefinitionInterface.
    + */
    +
    +namespace Drupal\Component\Plugin\Definition;
    

    @file needs to be removed now.

  2. +++ b/core/lib/Drupal/Component/Plugin/Definition/MergeablePluginDefinitionInterface.php
    @@ -0,0 +1,39 @@
    +   * @return $this
    +   */
    +  public function mergeDefaultDefinition(PluginDefinitionInterface $other_definition);
    

    so this doesn't actually return $this, it returns $other_definition, right? I think we use "@return static" (same class, but not this object) in this case? could be wrong.

  3. +++ b/core/lib/Drupal/Component/Plugin/Definition/PluginDefinitionInterface.php
    @@ -5,7 +5,7 @@
      *
    - * Object-based plugin definitions MUST implement this interface.
    + * Object-based plugin definitions MUST implement this interface. They can also optionally implement any of the following interfaces.
      *
      * @ingroup Plugin
      */
    

    uh.. what interfaces? :) Also 80 characters..

  4. +++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
    @@ -98,14 +106,17 @@ protected function getDerivatives(array $base_plugin_definitions) {
    -        foreach ($derivative_definitions as $derivative_id => $derivative_definition) {
    +        foreach ($derivative_definitions as $derivative_id => $derivative_plugin_definition) {
    

    is this rename necessary, makes the diff harder to read.

  5. +++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
    @@ -203,35 +214,78 @@ protected function getDeriver($base_plugin_id, $base_definition) {
    +    $plugin_id = NULL;
    +    if ($base_definition instanceof PluginDefinitionInterface) {
    +      if ($base_definition instanceof PluginInspectionDefinitionInterface) {
    +        $plugin_id = $base_definition->getId();
           }
    -      if (!is_subclass_of($class, '\Drupal\Component\Plugin\Derivative\DeriverInterface')) {
    -        throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" must implement \Drupal\Component\Plugin\Derivative\DeriverInterface.', $base_definition['id'], $class));
    +      if ($base_definition instanceof PluginDeriverDefinitionInterface) {
    +        $class = $base_definition->getDeriverClass();
           }
         }
    

    I'm not sure how exactly you use plugin definition objects in plugin.module. you have some kind of decorators, but they will only come in play later, right?

    but afaik at least in core, entity types are still the only example that use objects. Which actually do not support derivers *at all* (":" is not a valid character for an entity type)

    IMHO, it would be acceptable to only solve it here for arrays, which would solve it at least for the core plugin types. Because that would *greatly* simply this patch and remove all the controversial parts. Right now, you're doing much more than what the issue says.

tim.plunkett’s picture

+++ b/core/lib/Drupal/Component/Plugin/Definition/PluginDeriverDefinitionInterface.php
@@ -0,0 +1,40 @@
+interface PluginDeriverDefinitionInterface extends PluginDefinitionInterface, MergeablePluginDefinitionInterface {
...
+  public function setDeriverClass($class);

+++ b/core/lib/Drupal/Component/Plugin/Definition/PluginInspectionDefinitionInterface.php
@@ -0,0 +1,38 @@
+interface PluginInspectionDefinitionInterface extends PluginDefinitionInterface {
...
+  public function setId($id);
...
+  public function getId();

Not that we really need a getProvider() on these, for \Drupal\Core\Plugin\DefaultPluginManager::findDefinitions() to use. Having to work around this currently in #2296423: Implement layout plugin type in core

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new2.46 KB
new21.14 KB

@file needs to be removed now.

Fixed.

so this doesn't actually return $this, it returns $other_definition, right? I think we use "@return static" (same class, but not this object) in this case? could be wrong.

It does. The docblocks describe the methods of merging $other_definition into $this. Plugin definitions are assumed to be mutable, but I'm fine with changing this to @return static as that's more conservative and would potentially allow immutability at some point in the future, especially as return $this; does not violate @return static.

uh.. what interfaces? :) Also 80 characters..

Fixed.

is this rename necessary, makes the diff harder to read.

Not necessary. I renamed $derivative_definition to $derivative_plugin_definition for consistency with $plugin_definition in the same bit of code to help me understand the code better, and kept it because I thought it would help.
If you disagree with this change, we can revert it.

I'm not sure how exactly you use plugin definition objects in plugin.module. you have some kind of decorators, but they will only come in play later, right?

but afaik at least in core, entity types are still the only example that use objects. Which actually do not support derivers *at all* (":" is not a valid character for an entity type)

IMHO, it would be acceptable to only solve it here for arrays, which would solve it at least for the core plugin types. Because that would *greatly* simply this patch and remove all the controversial parts. Right now, you're doing much more than what the issue says.

Not doing this for object-based definition means core actively discourages people even more from improving DX on their own. We officially allow definitions to be arrays or objects, so my opinion is that any code must support both in such a way that we don't make object support worse than it currently is. If we solve this problem for arrays, but not for objects, there's not technically a regression, but we do introduce an inconsistency.

Not that we really need a getProvider() on these, for \Drupal\Core\Plugin\DefaultPluginManager::findDefinitions() to use. Having to work around this currently in #2296423: Implement layout plugin type in core

Not or Note? We can introduce another optional interface and document its usage on PluginDefinitionInterface. I don't know to which extent we can enforce its usage, though. Any thoughts on that?

tim.plunkett’s picture

+++ b/core/lib/Drupal/Component/Plugin/Definition/PluginInspectionDefinitionInterface.php
@@ -0,0 +1,33 @@
+interface PluginInspectionDefinitionInterface extends PluginDefinitionInterface {

I meant "Note". And my idea was to include getProvider/setProvider methods on this interface, rather than add Yet Another Plugin Definition Interface.
We can check for it in DefaultPluginManager in a follow-up.

Also I think this should be marked to be merged into PDI itself for D9. Class, ID, Provider are all really essential, and are Component level stuff (Compare to \Drupal\Component\Annotation\AnnotationInterface)

tim.plunkett’s picture

I withdraw my request to include getProvider here, that is squarely out of scope, and since we can't change PluginDefinitionInterface anyway, it might as well stay separate: #2818653: Allow object-based plugin definitions to be processed in DefaultPluginManager::findDefinitions()

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joachim’s picture

> Most, if not all derivers do not set plugin IDs for derivative definitions explicitly, but provide it by merging in the base field definition for defaults

'base field definition'?

Also, it would really help to have some examples in this explanation.

tim.plunkett’s picture

I believe that was meant to say "base plugin definition", as in the parameter name of the method
public function getDerivativeDefinitions($base_plugin_definition) {

\Drupal\system\Plugin\Derivative\SystemMenuBlock is a concise example:

  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->menuStorage->loadMultiple() as $menu => $entity) {
      $this->derivatives[$menu] = $base_plugin_definition;
      $this->derivatives[$menu]['admin_label'] = $entity->label();
      $this->derivatives[$menu]['config_dependencies']['config'] = [$entity->getConfigDependencyName()];
    }
    return $this->derivatives;
  }
joachim’s picture

So, just to check I get it -- what this issues is about is that if I do:

    foreach ($this->somePluginManager->getDefinitions() as $plugin_id => $definition) {

then all the $plugin_id values are correct, and for derivatives will be of the form base_plugin_id:derivative_id, but for derivatives, the $definition item contains only the base_plugin_id, so that multiple $definition values will have the same ID in them.

Where:
- the base_plugin_id is the ID specified in the plugin class annotation alongside the deriver property that gives the deriver class name
- the derivative_id is the ID keyed into $this->derivatives[$plugin_id] in DeriverBase::getDerivativeDefinitions()

If that's the case, then yup, it's a pain, as all plugin deriver classes are having to put this into the definition themselves in getDerivativeDefinitions().

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

psf_’s picture

Status: Needs review » Needs work

The last patch doesn't apply to D8.7.10.

I have this problem witch field types, I extend from EntityReferenceItem and it's listed with the same label that it, it not use the new label.

jungle’s picture

Issue tags: +Needs reroll
swatichouhan012’s picture

Status: Needs work » Needs review
StatusFileSize
new12.04 KB

Re rolled patch.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

hardik_patel_12’s picture

StatusFileSize
new8.53 KB

Re-roll for 9.1.x.

hardik_patel_12’s picture

Kindly ignore last patch , because patch at #55 and #53 are identical , i am triggering test for 9.1.x branch on #53. So patch at #55 is not needed sorry for that.

jofitz’s picture

StatusFileSize
new12.25 KB

Re-roll based on last patch that successfully applied (#39).

deepakaryan1988’s picture

Assigned: Unassigned » deepakaryan1988
Status: Needs work » Active
deepakaryan1988’s picture

Assigned: deepakaryan1988 » Unassigned
Status: Active » Needs review
StatusFileSize
new11.87 KB

Rerolled the patch based on #57

deepakaryan1988’s picture

Assigned: Unassigned » deepakaryan1988
Status: Needs review » Active
deepakaryan1988’s picture

Assigned: deepakaryan1988 » Unassigned
Status: Active » Needs review
StatusFileSize
new11.65 KB

Rerolled it again.

jpatel657’s picture

Assigned: Unassigned » jpatel657
jpatel657’s picture

Assigned: jpatel657 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new12.28 KB

Code sniffer issue has been fixed.

martin107’s picture

Issue tags: -Needs reroll
quietone’s picture

Thanks everyone for the recent patches and moving this issue forward. To make it easier to review please provide an interdiff or a diff when uploading a patch.

jibran’s picture

Issue tags: +Bug Smash Initiative

First of all, thank you all for looking into the issue and try to reroll the patch. There is a major problem with rerolls.

#2296423: Implement layout plugin type in core Added \Drupal\Component\Plugin\Definition\DerivablePluginDefinitionInterface which is almost same as \Drupal\Component\Plugin\Definition\PluginDeriverDefinitionInterface in this patch that is why this patch needs be recreated from #39 again.

All the rerolls since #39 are useless and missing the pieces of the code and no one tried to understand the code changes while removing conflicts so I'm removing commit credit from all the patch rerolls.

jibran’s picture

To all the who tried to help with the reroll. If you can't understand the code conflict feel free to ask questions here or in the drupal slack contribute channel.

Please, please don't overwhelm the reviewers with too many patches which are not helpful in moving the issue forward.

We need to create a new patch by looking at #39. We don't want to reroll #39.

Updated IS from the discussion #43, #44, and #45.

quietone’s picture

Status: Needs work » Needs review
Issue tags: +Bug Smash Initiative
StatusFileSize
new20.63 KB
new15.05 KB

@jibran, thanks for the clarification.

I read through the issue and noted that Berdir commented in the last paragraph of #37 that it would be fine to solve it here for arrays and simplify the patch. In reply, #39, Xano makes a good argument that not doing this for object based definitions introduces an inconsistency. For myself, I don't like inconsistencies at all and support that idea. However, adding it here does make the patch more complex and perhaps that is one of the factors why this issue hasn't been resolved yet. So, despite my preference for consistency let's stick to solving for arrays here. Anything else can be a followup.

In that light I have made a new patch. And then to see if it actually work I used it in Migration. Specifically, \Drupal\migrate\Plugin\MigrationPluginManager::expandPluginIds() can be removed. That functionality is still needed in tests so it now resides in MigrateTestBase.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new4.23 KB
new10.29 KB

So, that isn't going to work. Many of the migrate failures are in \Drupal\migrate\Plugin\Migration::checkRequirements() and even if that passed it would fail in the MigrateLookup service anyway. So, this removes the migrate changes.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new455 bytes
new10.84 KB

This should fix the two failing migration tests. As for the other tests, I don't know. Can someone else look into the remaining failures?

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.11 KB
new11.15 KB

This may fix the migrate failures.

jibran’s picture

Nice work with recreating the patch.

+++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
@@ -981,7 +981,7 @@ public function getHighestId() {
-        if ($migration['id'] === $base_id) {
+        if ($base_id === substr($migration_id, 0, strpos($migration_id, $this::DERIVATIVE_SEPARATOR))) {

Maybe set a base_id as well on all the plugins?

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new2.84 KB
new11.08 KB

I was thinking the same thing.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new8.88 KB
new10.71 KB

Fixing tests and a bit of cleanup.

jibran’s picture

+++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
@@ -981,7 +981,7 @@ public function getHighestId() {
+        if ($base_id === substr($migration_id, 0, strpos($migration_id, $this::DERIVATIVE_SEPARATOR))) {

This can just be strpos($migration_id, $base_id) === 0.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new829 bytes
new10.71 KB

Actually, I prefer if ($base_id === ($migration['base_id'] ?? NULL)) where we actually use the new base_id on the plugin definition.

I have looked into the three remaining errors and haven't made any progress on fixing them. Two are in areas I don't know at all. One is a FuncationalJavascript test and I have never been able to run them locally let alone debug them. Another is in content_moderation\Functional\ModerationActionsTest. I must admit that there are two migration issues related to content_moderation so I will have to dabble in it but I haven't started yet. The final one is Derivative test and it eludes me why adding the base_id to the expected causes the failure.

hash6’s picture

Assigned: Unassigned » hash6

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.28 KB
new10.65 KB

@hash6, are you still planning to work on this?

I noticed this needs a reroll, so here it is. There are still failing tests.

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new11.1 KB
new947 bytes

Fixing fail tests.

tim.plunkett’s picture

  1. +++ b/core/tests/Drupal/KernelTests/Core/Plugin/DerivativeTest.php
    @@ -19,10 +19,27 @@ class DerivativeTest extends PluginTestBase {
    +    $expected = $this->mockBlockExpectedDefinitions;
    ...
         foreach ($this->mockBlockExpectedDefinitions as $id => $definition) {
    

    $this->mockBlockExpectedDefinitions should be changed directly, where it is defined.

  2. +++ b/core/tests/Drupal/KernelTests/Core/Plugin/DerivativeTest.php
    @@ -19,10 +19,27 @@ class DerivativeTest extends PluginTestBase {
    +      } elseif ($id == "menu:navigation") {
    

    This is violating the coding standards, that's why the test failed. elseif should start a newline.

    But no need to fix it, due to my first point of feedback

vsujeetkumar’s picture

StatusFileSize
new10.73 KB
new1.05 KB

Done with the changes advised by @tim.plunkett

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new12.1 KB
new1.18 KB

Fixing fail test.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

dhirendra.mishra’s picture

StatusFileSize
new12.17 KB

Re-rolled this against 9.3.x as previous patch was not applied to 9.3.x automatically.

mohit_aghera’s picture

Assigned: hash6 » Unassigned
Status: Needs work » Needs review

Changing to needs review so test bot can pick it up.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: -classed plugin definitions

Addressed my own feedback from #92, switched from patches to a MR, and fixed the tests.

berdir’s picture

Added a comment about the comments, for the id change I guess we just have to do a change notice and hope that we don't break too many things :)

tim.plunkett’s picture

The last thing to consider is the addition of base_id.

As seen in the changes to content_moderation_action_info_alter() and layout_builder_plugin_filter_block_alter(), it is helpful for any code dealing with checking definitions.

It also covers up a bug in the actions system, see #2916740-117: Add generic entity actions

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new149 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.