Problem/Motivation

The Entity migrate destination plugin doesn't implement the fields() method, and so does not allow reporting of the available fields of the destination entity.

This means that developers can't get a listing of the destination fields to help them when writing a migration. This is a blocker for #2630718: Implement drush migrate-fields-destination.

Steps to reproduce

Look at the code:

  public function fields() {
    // TODO: Implement fields() method.
  }

;)

Proposed resolution

Implement the method in EntityContentBase.

The method should return both base fields on the destination entity type and bundle fields. To detect the destination bundle, the following methods should be tried, in this order:

1. the migration's destination configuration specifies 'default_bundle'
2. the destination entity type has no bundles, in which case there are no bundle fields (e.g. user)
3. the destination entity type has only 1 bundle, it must be that one (e.g. if there's only the 'article' node type defined)

The EntityContentBase class will need the 'entity_type.bundle.info' service injecting.

Remaining tasks

  1. Make a followup
  2. Add missing return type in the kernel test. (See Comment #144. Novice task.)
  3. Rebase on the current 11.x and resolve conflicts from #3474640: Drupal\Tests\migrate\Unit\destination\EntityRevisionTest uses weird mocking pattern. (See Comment #150. Novice task.)

User interface changes

None.

API changes

The \Drupal\migrate\Plugin\migrate\destination\EntityContentBase::__construct() method has an additional parameter,\Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info.

Classes that extend this will need to add the parameter to their call to the parent __construct().

Data model changes

None.

Release notes snippet

N/A

Original report by mikeryan

Went to implement #2630718: Implement drush migrate-fields-destination and got no output, because:

  public function fields(MigrationInterface $migration = NULL) {
    // TODO: Implement fields() method.
  }

D'oh!

Some introspection necessary here. Ideally, if we followed the D7 migration model, the destination instance in a migration would have a specific bundle assigned, so we would be able to retrieve bundle-specific fields here. That's not true in D8, the bundle is assumed to be pulled per-row from the source data so can't be statically determined. That's... unfortunate, and would seem to require an architectural change (I would love if destinations could be configured like entity:node:article). But at least for now we can pull the base properties here.

CommentFileSizeAuthor
#169 entity-fields-migration-destination-10.4.x-2630732-169.patch76.29 KBsmulvih2
#162 2630732-nr-bot.txt129 bytesneeds-review-queue-bot
#161 entity-fields-migration-destination-10.3.x-2630732-161.patch25.39 KBsmulvih2
#149 2630732-nr-bot.txt90 bytesneeds-review-queue-bot
#143 2630732-nr-bot.txt90 bytesneeds-review-queue-bot
#123 D103-2630732-123.patch26.14 KBjan kellermann
#123 D102-2630732-123.patch26.11 KBjan kellermann
#116 D95x-2630732-115.patch22.02 KBsylus
#115 D95x-2630732-114.patch.patch22.02 KBsylus
#113 2630732-113.patch25.65 KBsakthi_dev
#111 2630732-111.patch25.65 KBsakthi_dev
#107 D10x-implement_entity_fields_for_migration_dest-2630732-107.patch21.11 KBjoseph.olstad
#103 D93x-implement_entity_fields_for_migration_dest-2630732.patch21.23 KBjoseph.olstad
#83 2630732-interdiff_82_83.txt787 bytesjoseph.olstad
#83 D93x-migrate_fixes-2630732-83.patch12.22 KBjoseph.olstad
#82 D93x-migrate_fixes-2630732-82.patch12.19 KBjoseph.olstad
#77 2630732-77.patch10.17 KBquietone
#77 interdiff-76-77.txt5.39 KBquietone
#76 interdiff_74-76.txt867 bytesridhimaabrol24
#76 2630732-76.patch9.34 KBridhimaabrol24
#74 interdiff_70-74.txt567 bytesridhimaabrol24
#74 2630732-74.patch9.33 KBridhimaabrol24
#71 2630732-70.patch9.34 KBkishor_kolekar
#65 interdiff-63-65.txt2.1 KBaleevas
#65 2630732-65.patch9.38 KBaleevas
#63 2630732-63.patch9.43 KBshubham.prakash
#61 2630732-61.patch9.42 KBshubham.prakash
#59 2630732-59.drupal.Implement-Entityfields-for-migration-destinations.patch9.75 KBBen Buske
#55 2630732-55.drupal.Implement-Entityfields-for-migration-destinations.patch15.03 KBjoachim
#47 interdiff.txt11.63 KBquietone
#47 2630732-47.patch15.03 KBquietone
#44 2630732-44.patch14.93 KBheddn
#44 interdiff_43-44.txt4.31 KBheddn
#43 2630732-43.patch17.08 KBheddn
#43 interdiff_42-43.txt3.12 KBheddn
#42 2630732-42.patch16.71 KBjofitz
#35 implement-2630732-35.patch17.98 KBsylus
#30 interdiff.txt12.53 KBmallezie
#30 2630732-30.patch16.46 KBmallezie
#29 interdiff.txt14.31 KBmallezie
#29 2630732-29.patch11.04 KBmallezie
#26 interdiff.txt761 bytesmallezie
#26 2630732-26.patch17.61 KBmallezie
#24 interdiff.txt1.36 KBmallezie
#24 2630732-24.patch17.62 KBmallezie
#21 implement_entity_fields_migrate-2630732-21.patch17.44 KBsylus
#17 interdiff.txt2.44 KBmallezie
#17 2630732-fields-migration-destionation-17.patch19.19 KBmallezie
#15 interdiff.txt2.97 KBmallezie
#15 2630732-fields-migration-destionation-15.patch16.75 KBmallezie
#13 interdiff.txt1.13 KBmallezie
#13 2630732-fields-migration-destionation-13.patch25.52 KBmallezie
#11 interdiff.txt1.13 KBmallezie
#11 2630732-fields-migration-destionation-11.patch14.7 KBmallezie
#8 2630732-fields-migration-destionation-8.patch13.57 KBmallezie
#2 2630732-fields-migration-destionation.patch875 bytesmallezie

Issue fork drupal-2630732

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

mikeryan created an issue. See original summary.

mallezie’s picture

Status: Active » Needs review
StatusFileSize
new875 bytes

This does the trick for the base fields.
We should look how we could get the more granular fields for each bundle. Not only for the drush command, but also for the UI. #2470916: Implement the migration detail page

Perhaps we should split this up, add the basefields here, and discuss the architectural changes needed to get the bundle specific fields in a seperate issue.

heddn’s picture

Some of the boilerplate for this could probably be grabbed from the patch at #2642612: Create Entity Lookup & Generate process Base plugins.

heddn’s picture

The hard part is knowing the destination bundle. Because it isn't always required (bundle-less entities) nor is it in the same place or named the same thing across different types of entities (taxonomy terms use vocabulary, nodes use type, other entities use something different).

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.

mikeryan’s picture

Issue tags: +Needs tests
mikeryan’s picture

Status: Needs review » Postponed

Let's do this after #2700581: Destination bundle set in destination plugin, not in process, and support bundle fields when the destination has a bundle set.

mallezie’s picture

Status: Postponed » Needs review
StatusFileSize
new13.57 KB

Since #2700581: Destination bundle set in destination plugin, not in process is getting close, i started rerolling and expanding this one.
I added the base fields and expanded with all the fields.

Status: Needs review » Needs work

The last submitted patch, 8: 2630732-fields-migration-destionation-8.patch, failed testing.

mallezie’s picture

I can probably fix the test fails here, but i'm not sure if injecting the EntityFieldManager and thus changing the constructor is even allowed from a BC perspective.
If anyone could confirm this is the good or wrong direction, i'm happy to work further on this, and bring this home.

mallezie’s picture

Status: Needs work » Needs review
StatusFileSize
new14.7 KB
new1.13 KB

Just a small test to see if i can figure out how to fix the test fails. This should fix 1 of the failing tests.

Status: Needs review » Needs work

The last submitted patch, 11: 2630732-fields-migration-destionation-11.patch, failed testing.

mallezie’s picture

Status: Needs work » Needs review
StatusFileSize
new25.52 KB
new1.13 KB

Next try, should work ;-)

Status: Needs review » Needs work

The last submitted patch, 13: 2630732-fields-migration-destionation-13.patch, failed testing.

mallezie’s picture

Status: Needs work » Needs review
StatusFileSize
new16.75 KB
new2.97 KB

Better create the correct patches, so ignore the previous one

Status: Needs review » Needs work

The last submitted patch, 15: 2630732-fields-migration-destionation-15.patch, failed testing.

mallezie’s picture

Status: Needs work » Needs review
StatusFileSize
new19.19 KB
new2.44 KB

And some more test fixes. Next up writing tests for the new code.

mallezie’s picture

Status: Needs review » Needs work

Woohoo test pass. However not sure how to add a test for the new method. So need to leave this open. Anyhow blocked on #2700581: Destination bundle set in destination plugin, not in process before this is functional and can be tested. So gonna leave it open for now.

mallezie’s picture

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

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should 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.

sylus’s picture

The patch was no longer working for me in 8.x-2.x-dev:

patch -p1 < 2630732-fields-migration-destionation-17.patch
patching file core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
patching file core/modules/file/src/Plugin/migrate/destination/EntityFile.php
Hunk #1 FAILED at 4.
Hunk #2 FAILED at 40.
Hunk #3 FAILED at 48.
Hunk #4 FAILED at 66.
4 out of 4 hunks FAILED -- saving rejects to file core/modules/file/src/Plugin/migrate/destination/EntityFile.php.rej
patching file core/modules/migrate/src/Plugin/migrate/destination/Entity.php
patching file core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
Hunk #1 succeeded at 5 with fuzz 1.
Hunk #2 succeeded at 50 (offset 1 line).
Hunk #3 succeeded at 75 (offset 1 line).
patching file core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php
Hunk #1 succeeded at 42 (offset 1 line).
Hunk #2 succeeded at 55 (offset 1 line).
Hunk #3 succeeded at 69 (offset 1 line).
Hunk #4 succeeded at 99 (offset 1 line).
patching file core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php
patching file core/modules/migrate_drupal/src/Plugin/migrate/destination/EntityFieldStorageConfig.php
patching file core/modules/user/src/Plugin/migrate/destination/EntityUser.php
Hunk #2 FAILED at 44.
Hunk #3 succeeded at 53 (offset -2 lines).
Hunk #4 succeeded at 70 (offset -2 lines).
1 out of 4 hunks FAILED -- saving rejects to file core/modules/user/src/Plugin/migrate/destination/EntityUser.php.rej

The file EntityFile.php no longer has its constructors and merely extends from EntityContentBase.php so I have just removed that file. Finally I have corrected the minor issue with a comment in EntityUser.php

sylus’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 21: implement_entity_fields_migrate-2630732-21.patch, failed testing.

mallezie’s picture

Version: 8.2.x-dev » 8.3.x-dev
Status: Needs work » Needs review
StatusFileSize
new17.62 KB
new1.36 KB

Thanks, i rerolled your work against 8.3.x, and fixed the new test fails. This is probably 8.3.x material at this time.

heddn’s picture

Status: Needs review » Needs work

Mostly nits & questions. The last one, if I understand what is going on correctly though, should be addressed.

  1. +++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php
    @@ -107,7 +119,22 @@ public function getBundle(Row $row) {
    +    $entity_type_id = self::getEntityTypeId($this->getPluginId());
    

    Should this be $this?
    Does this handle revisions too? I'd like to see a test using both a revision and a non-revision.

  2. +++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php
    @@ -107,7 +119,22 @@ public function getBundle(Row $row) {
    +    $fields = array();
    

    New code, is it possible to use the new array syntax? Check around, are we already using it in this class?

  3. +++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php
    @@ -107,7 +119,22 @@ public function getBundle(Row $row) {
    +    foreach ($base_definitions as $base_field) {
    ...
    +    if (isset($this->configuration['default_bundle'])) {
    

    I think we should do an if/else here. If we have the default bundle, no need to add extra fields into the mix.

    i.e. if default bundle... gather them. else gather all from base field definitions.

mallezie’s picture

Status: Needs work » Needs review
StatusFileSize
new17.61 KB
new761 bytes

Thanks for the review.

1. Since protected static function getEntityTypeId() is a static function and Entity is an abstract class self is more appropriate if i recall correctly.
2. No other arrays in this class, but changed to new syntax. Nice catch.
3. It's actually the other way around, when a default_bundle is around we can add the default specific fields. This value is set in the migration destiny. it was added in #2700581: Destination bundle set in destination plugin, not in process. So i think this way is correct. Add the default entity fields, and when we got the bundle specified in 'default_bundle' add the bundle specific fields as well.

I don't think revisions are on order here. Migration destinations are not revisionable AFAICT.
This indeed needs some tests, but i have not really an idea how to start with those tests.

mikeryan’s picture

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

No BC change here, no reason we can't get this into 8.2.1 or 8.2.2.

mikeryan’s picture

Issue tags: +Migrate BC break

Ooh, should've actually looked at the patch first, adding entity field manager into the middle of the constructor arguments, so that is a BC break (which, we're trying to be done with as of 8.2.0).

For BC, could we add that to the end of each constructor as an optional argument, so any classes extending those destinations won't break?

mallezie’s picture

StatusFileSize
new11.04 KB
new14.31 KB

Thanks for the feedback. This causes some inconsistency in the constructors, but that's probably not a problem. Let's remove also the test changes, to see if this is acutally BC.

mallezie’s picture

StatusFileSize
new16.46 KB
new12.53 KB

With help from @chx, i rewrote the fields method, and finally found a way to add a test.

Instead of showing only basefields for a destination we return all fields from all bundles of the entity. This is actually also more logical, and does what the interface says, show all posibble destination fields.

I also added a test, and did some minor code changes. Interdiff is added to be complete, but almost size of the patch.

mallezie’s picture

Just to note: According to me the entity destination class is actually untested.

ckaotik’s picture

Status: Needs review » Needs work

Thanks all for the work on this!

Just tried the patch, and found a problem: This fails with a LogicException when the entity type is not fieldable (see EntityFieldManager::buildBaseFieldDefinitions). This is the case, for example, when migrating node type configuration entities and probably quite common.

heddn’s picture

Issue tags: -Migrate BC break

Removing the bc breaking tag since we're providing the additional construction argument.

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

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should 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.

sylus’s picture

Status: Needs work » Needs review
StatusFileSize
new17.98 KB

Just attaching an updated patch to apply to both 8.3.x + 8.4.x branch (minor adjustments to EntityComment.php. Pushing to needs review just to trigger testbot.

ckaotik’s picture

Status: Needs review » Needs work

Thanks for the reroll. We still need to address the exception thrown on non-fieldable entities (e.g. config entities or custom content entities), which is probably easier once we have a test for that :)

$this->entityFieldManager->getFieldDefinitions and $this->entityFieldManager->getFieldStorageDefinitions($entity_type_id); will both throw a LogicException in \Drupal\Core\Entity\EntityFieldManager::buildBaseFieldDefinitions via

  if (!$entity_type->isSubclassOf(FieldableEntityInterface::class)) {
    throw new \LogicException("Getting the base fields is not supported for entity type {$entity_type->getLabel()}.");
  }

Basically, we might add that check ourselves and just bail out if the interface is not implemented by our destination entity type.

heddn’s picture

Do an is_subclass_of makes sense. I would expect that.

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

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should 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.

Ben Buske’s picture

We tried this patch with a book migration wich has as destination "plugin: book".
Because the function getEntityTypeId just cuts the first 7 letters to remove "entity:" that fails.
As quick fix we used this code:

public function fields(MigrationInterface $migration = NULL) {
  $entity_type_id = self::getEntityTypeId($this->getPluginId());
  if (!$entity_type_id && $this->storage) {
    $entity_type_id = $this->storage->getEntityTypeId();
  }

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

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.

joachim’s picture

Patch doesn't apply on 8.5.x unfortunately.

jofitz’s picture

StatusFileSize
new16.71 KB

Reroll.

Still need to address #36.

heddn’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new3.12 KB
new17.08 KB

I've just added a check for #36 over in #2935951-59: Copy migrate source plugin from migrate_drupal_d8 into migrate_drupal. Thanks for the pointer.

And I've added the same check here. And moved the fieldable logic down into EntityContentBase. I'm assuming that config entities are normally not fieldable. There's also tests now, so I've removed that tag.

heddn’s picture

StatusFileSize
new4.31 KB
new14.93 KB

And cleaned up the DI and imports for the base Entity class here.

The last submitted patch, 43: 2630732-43.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 44: 2630732-44.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new15.03 KB
new11.63 KB

Came across this waiting for a long test to run.

Fixed the failing test by declaring the entityFieldManger in EntityContentBase. Also did some renaming of the test migrations and node type to something more descriptive that just appending a '2' to signify the difference. The intentions was to make the code easier to understand.. There are also several fixes for coding standards.

Status: Needs review » Needs work

The last submitted patch, 47: 2630732-47.patch, failed testing. View results

quietone’s picture

Version: 8.5.x-dev » 8.6.x-dev
Status: Needs work » Needs review

Retest with 8.6.x

heddn’s picture

Status: Needs review » Needs work

Need to figure out a solution for the problem with not knowing the destination bundle. Since we don't know it, we cannot really pull up destination fields.

Perhaps we "standardize" on a method to designate the destination bundle that is optional. But if it is used, then trigger the Entity::fields logic for a destination.

My proposed standard is entity:node:page or entity:node:blog, etc.

Bumping back to NW for this piece.

mallezie’s picture

@heddn i'm not really sure i can follow the comment, as i saw it initially (and seems the patch still follows that). We can only show the base fields when we don't have a bundle specified. When we don't specify the bundle, the migration can migrate to different bundles in one migration, so we can't set a default one here?
This would mean, that fields() can only return the fields it's certain about, not all possible fields, but i think that's good. Better showing only correct fields, even if that means those are not all available fields, then showing possible 'wrong' fields.

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.

heddn’s picture

If we want to do this in 2 phases. Show base fields and bundle fields in a follow-up, that's fine. Let's open the follow-up though and link it in as an @TODO in this patch.

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.

joachim’s picture

Reroll of #47 for 8.7.x.

+++ b/core/modules/migrate/tests/modules/migrate_destination_test/migrations/node_with_fields.yml
@@ -0,0 +1,12 @@
+  default_bundle: test_node_type_with_fields

I'm assuming the 'default_bundle' property is something this patch invents -- so it needs to be documented in the class docs for the destination plugin.

I don't really follow #50 either... is 'default_bundle' not sufficient here?

mallezie’s picture

'default_bundle' was introduced in #2700581: Destination bundle set in destination plugin, not in process

Since an entity migration can migrate to different bundles in one migration we cannot specifiy the 'non' base fields of the target entity. When the migration specifices the 'default_bundle' property, we know it migrates to that specific bundle of the entity, and can request the non base fields of that bundle to add them in the destination.

I think #50 also missed the introduction of that in the 'preceeding' issue where it was introduced.

yonailo’s picture

Hello,

Two small issues related this patch (#55) maybe worth saying :

When testing a 'drush mfd' command (see: https://www.drupal.org/project/migrate_tools/issues/2630718) for a paragraphs destination migration. I have found that 'self::getEntityTypeId($this->getPluginId());' should be replaced by 'static::getEntityTypeId($this->getPluginId());'
inside the EntityContentBase:fields() function.

Afterwards, I also had to modify the _construct() function of EntityReferenceRevisions and EntityRevision classes to add the last parameter $entity_field_manager.

With these two small modification, I was able to execute the drush command that shows all migration destination fields for my paragraph type.

Hope this helps.

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.

Ben Buske’s picture

Status: Needs work » Needs review
StatusFileSize
new9.75 KB

rerolled for 8.8.x

mikelutz’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

NW for reroll, #53 and #57

shubham.prakash’s picture

Status: Needs work » Needs review
StatusFileSize
new9.42 KB

This should fix the php error.

Status: Needs review » Needs work

The last submitted patch, 61: 2630732-61.patch, failed testing. View results

shubham.prakash’s picture

Status: Needs work » Needs review
StatusFileSize
new9.43 KB

This should fix the failed test case.

Status: Needs review » Needs work

The last submitted patch, 63: 2630732-63.patch, failed testing. View results

aleevas’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new9.38 KB
new2.1 KB

Added fix for failed test

mikelutz’s picture

Status: Needs review » Needs work

This is still NW for #53 and #57

aleevas’s picture

Looks like all changes that was offered in #57already implemented in 8.9 branch:

I have found that 'self::getEntityTypeId($this->getPluginId());' should be replaced by 'static::getEntityTypeId($this->getPluginId());'
inside the EntityContentBase:fields() function.

 /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
    $entity_type = static::getEntityTypeId($plugin_id);
I also had to modify the _construct() function of EntityReferenceRevisions and EntityRevision classes to add the last parameter $entity_field_manager.
class EntityRevision extends EntityContentBase {

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager) {
    $plugin_definition += [
      'label' => new TranslatableMarkup('@entity_type revisions', ['@entity_type' => $storage->getEntityType()->getSingularLabel()]),
    ];
    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager);

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.

joseph.olstad’s picture

Patch needs reroll for 9.1.x
Patch applies cleanly to 9.0.x

kishor_kolekar’s picture

Assigned: Unassigned » kishor_kolekar
kishor_kolekar’s picture

Status: Needs work » Needs review
StatusFileSize
new9.34 KB

I have re-roll the patch for 9.1.x

kishor_kolekar’s picture

Assigned: kishor_kolekar » Unassigned
mikelutz’s picture

Status: Needs review » Needs work

The test module here needs to be updated to work with Drupal 9.

ridhimaabrol24’s picture

Status: Needs work » Needs review
StatusFileSize
new9.33 KB
new567 bytes

Trying to fix the test cases

Status: Needs review » Needs work

The last submitted patch, 74: 2630732-74.patch, failed testing. View results

ridhimaabrol24’s picture

Status: Needs work » Needs review
StatusFileSize
new9.34 KB
new867 bytes

Fixing failed test!

quietone’s picture

StatusFileSize
new5.39 KB
new10.17 KB

Started to review this and the changes to the User entity caught my eye, Why are those needed? They are not, so they are gone. And I've added a test for a user destination for verification. That required a changed to EntityContentBase::fields to get the fields for an entity that does not have bundles and therefor would be not setting the 'default_bundle' in the destination plugin configuration.

heddn’s picture

Status: Needs review » Needs work
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
@@ -375,4 +375,26 @@ public function getHighestId() {
+    $bundle = empty($this->configuration['default_bundle']) ? $entity_type->id() : $this->configuration['default_bundle'];
+    $field_definitions += $this->entityFieldManager->getFieldDefinitions($entity_type->id(), $bundle);

I think we can also pass the bundle in other ways. We should also return early or do some logic around this for when we don't know the bundle but the entity type is a bundle-able entity. I'm OK with not returning all the bundle fields, as returning something is better then nothing. But we should at least be a little more defensive.

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.

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.

joachim’s picture

@heddn I don't quite follow your points in #78.

> I think we can also pass the bundle in other ways

Could you say what other ways? Do you mean we should check for other ways in which the migration's destination bundle is defined in the migration?

> I'm OK with not returning all the bundle fields, as returning something is better then nothing.

Is the 'not' a typo in that sentence? It seems to contradict itself!

    $bundle = empty($this->configuration['default_bundle']) ? $entity_type->id() : $this->configuration['default_bundle'];

I agree this isn't quite right. For one thing, if a developer forgets to put in 'default_bundle' and it IS an entity type with bundles (maybe they are mapping the bundle from source data?), then this will take the entity type ID as the bundle, and pass it to entityFieldManager->getFieldDefinitions()... which will possibly throw an exception for an invalid bundle?

joseph.olstad’s picture

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

Reroll for no-fuzz on 9.3.x.

The patch has been in use for over a year with the WXT distribution. The patch applies on D9.1.x

If someone has a specific suggestion with the patch or implementation please provide helpful feedback.

There's no interdiff for this, straight up reroll.

joseph.olstad’s picture

StatusFileSize
new12.22 KB
new787 bytes

wow ya, code style restrictions, ftlog.

heddn’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
    @@ -374,4 +374,26 @@ public function getHighestId() {
    +  public function fields(MigrationInterface $migration = NULL) {
    

    $migration isn't used, nor is it on the parent method. Do we need it?

  2. +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
    @@ -374,4 +374,26 @@ public function getHighestId() {
    +    $bundle = empty($this->configuration['default_bundle']) ? $entity_type->id() : $this->configuration['default_bundle'];
    

    A bundle can be provided in 2 or 3 different ways. And if isn't set by default bundle, we would pass null value along to $this->entityFieldManager->getFieldDefinitions and get PHP errors.

    But let's take node as an example. There are base fields on it we could return; so return those, at least.

    We can try some of the other common ways to get the "bundle". Actually, that isn't really true. At the point that fields() is called, there be might be very little context provided. The only thing we really have is "default_bundle", because we don't have a Row object. But that means, we need to just return the base fields without any bundle ones. i.e. getBaseFieldDefinitions

joachim’s picture

Thanks for clarifying @heddn

> We can try some of the other common ways to get the "bundle".
> At the point that fields() is called, there be might be very little context provided.

Here's what I think we can try at that point, in the order to attempt them (and complexity)

1. default_bundle
2. if the destination entity type has no bundles: there are no bundle fields (e.g. user)
3. if the destination entity type has only 1 bundle, it must be that one (e.g. if there's only the 'article' node type defined)
4. if the bundle field on the destination entity is mapped from a constant value, it's that
5. if the bundle field on the destination entity is mapped from a source field, and that source field is in the source query as a fixed value condition, it's that

I'm not sure about whether 4 is worth the effort. 5 is definitely not worth the effort IMO. 2 and 3 are pretty simple though.

heddn’s picture

I think I agree about 1,2,3. But 4 and 5 require data outside the scope of the destination and might not be data available so let's keep it simple for now. maybe we can hit those in follow-up issues, if we even think that is worth it.

joachim’s picture

Status: Needs work » Needs review

> I think I agree about 1,2,3. But 4 and 5 require data outside the scope of the destination and might not be data available so let's keep it simple for now. maybe we can hit those in follow-up issues, if we even think that is worth it.

Agreed. Maybe a follow-up for 4.

quietone’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Came to review but the IS is not up to date. In #85 and #86 it was agreed that certain cases should be implemented. Has that happened? Tagging for IS update.

joachim’s picture

joachim’s picture

quietone’s picture

@joachim, thanks that helped!

joachim’s picture

Assigned: Unassigned » joachim

Working on fixing the tests...

joachim’s picture

Assigned: joachim » Unassigned

Fixed tests and moved stuff from the test module into the test class as in the review.

Unsure about a couple of points in @quietone's review -- see review threads.

joseph.olstad’s picture

The above merge request no longer applies cleanly to the head of 9.3.x

wget https://git.drupalcode.org/project/drupal/-/merge_requests/907.diff
 ╰❯ $ patch -p1 --dry-run < 907.diff 
checking file core/modules/comment/src/Plugin/migrate/destination/EntityComment.php
Hunk #1 succeeded at 4 with fuzz 2.
Hunk #2 FAILED at 54.
Hunk #3 FAILED at 74.
2 out of 3 hunks FAILED
checking file core/modules/migrate/src/Plugin/migrate/destination/Entity.php
checking file core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
Hunk #1 succeeded at 6 with fuzz 1.
Hunk #2 succeeded at 101 with fuzz 2 (offset -3 lines).
Hunk #3 FAILED at 130.
Hunk #4 FAILED at 150.
Hunk #5 succeeded at 422 (offset 40 lines).
2 out of 5 hunks FAILED
checking file core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php
Hunk #1 succeeded at 5 with fuzz 2.
Hunk #2 FAILED at 115.
1 out of 2 hunks FAILED
checking file core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php
Hunk #1 succeeded at 317 with fuzz 2 (offset 224 lines).
checking file core/modules/migrate/tests/src/Kernel/MigrateEntityDestinationTest.php
checking file core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php
Hunk #1 succeeded at 8 with fuzz 2.
Hunk #2 FAILED at 89.
1 out of 2 hunks FAILED
checking file core/modules/user/src/Plugin/migrate/destination/EntityUser.php
Hunk #2 FAILED at 94.
Hunk #3 FAILED at 116.
2 out of 3 hunks FAILED

The source branch is 379 commits behind the target branch

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.

mikran made their first commit to this issue’s fork.

mikran’s picture

Rebased and conflicts fixed.

First push was rebase to 9.3.x but then I realized I need to do it to 9.4.x and that is the second push. No conflicts with the second one.

joachim’s picture

Status: Needs work » Needs review

Rebased to 9.4.x.

quietone’s picture

Status: Needs review » Needs work

In Slack, joachim asked me to review this.

quietone’s picture

joachim’s picture

Status: Needs work » Needs review

I don't seem to be able to get to the MR comments to mark them as resolved -- possibly because I've rebased?

Anyway, points from reviews have been addressed:

- documentation of new @throw
- moved new test into the existing class.

joseph.olstad’s picture

Status: Needs review » Needs work

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.

joseph.olstad’s picture

new patch for D10.0.x / D10.1.x

straight up reroll of #103

joseph.olstad’s picture

Status: Needs work » Needs review
benjifisher’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

The issue description makes this seem straightforward: implement the method. But looking at the patch, it seems more complicated than that. We are adding parameters to constructors, for example. I see some discussion of backwards compatibility (BC) in Comments #10, #28, and others. But I would like to see that discussion (and why we need to change the constructors for this issue) in the issue summary, so I am adding the tag for that. It will be easier to review this issue if we do not have to read all the comments to get that explained.

The patch in #107 failed static analysis. Unfortunately, the testbot does not set the issue to NW when that happens, so I am changing the status now. Just looking at the PHPStan report, and not looking too closely at the patch, it seems that the static analysis is catching a pretty serious problem:

constructor invoked with 9 parameters, 10 required.

joachim’s picture

> We are adding parameters to constructors, for example. I see some discussion of backwards compatibility (BC) in Comments #10, #28, and others.

Adding to constructors is a fairly standard change. We need the bundle info service to get the bundles of the entity type in question.

We do need to add BC handling, even though technically it's internal, as lots of things will be extending this class.

> But I would like to see that discussion (and why we need to change the constructors for this issue) in the issue summary, so I am adding the tag for that. It will be easier to review this issue if we do not have to read all the comments to get that explained.

That's already in there, where it says "To detect the destination bundle, the following methods should be tried, in this order".

sakthi_dev’s picture

StatusFileSize
new25.65 KB

Resolved the custom command fails.

joachim’s picture

> 2. the destination entity type has no bundles, in which case there are no bundle fields (e.g. user)

It occurs to me that it would still be possible to define bundle fields on an entity type with no bundle. For example, you might have something that always defines fields as bundle fields, on different entity types.

I've not checked the code, but what it should do here is take the one single bundle that's defined by default by the entity system.

sakthi_dev’s picture

StatusFileSize
new25.65 KB

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.

sylus’s picture

StatusFileSize
new22.02 KB

Just attaching a re-roll for 9.5.x so patch works against 9.5.10

sylus’s picture

StatusFileSize
new22.02 KB

Just attaching a re-roll for 9.5.x so patch works against 9.5.10

donquixote made their first commit to this issue’s fork.

donquixote’s picture

At first I wanted to rebase the original MR, but this was not practical.
So now a new MR.

joseph.olstad’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs subsystem maintainer review

Left some comments on the MR.

I see @quietone has been involved so the submaintainer tag may not be needed but added just in case.

vlyalko’s picture

The patch #113 no longer applying for me in 10.3

jan kellermann’s picture

StatusFileSize
new26.11 KB
new26.14 KB

I post our patches for D10.2(.7) and 10.3.
The patches are the changes from patch 113 adapted to the current code.
We are not doing migrations at this time, so it is not tested for migrations in real life.

benjifisher changed the visibility of the branch 2630732-migration-destinations-entity-fields to hidden.

benjifisher’s picture

In Comment #109, I asked for an issue summary update.

In Comment #110, the tag was removed without updating the issue summary.

Comment #121 adds the tag for subsystem maintainer review. Please do what the subsystem maintainer requests before adding that tag back.

Since DrupalCI shut down, we no longer run automated tests on patches. If anyone cares to move this issue forward, then it would help to convert the latest patch to a MR (and to update the issue summary).

I am hiding the original MR (for 9.4.x). The newer MR (for 11.x) needs work.

benjifisher’s picture

joachim’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

> We are adding parameters to constructors, for example. I see some discussion of backwards compatibility (BC) in Comments #10, #28, and others. But I would like to see that discussion (and why we need to change the constructors for this issue) in the issue summary, so I am adding the tag for that. It will be easier to review this issue if we do not have to read all the comments to get that explained.

We need to change the constructors because the EntityContentBase class will need the 'entity_type.bundle.info' service injecting so it can know about bundles.

I do not think this sort of detail needs to be explained in the proposed resolution. Adding a service is like adding a variable.

benjifisher’s picture

Thanks for updating the issue description.

It would be nice to finish up this old issue.

I had a look at the MR. (I got most of the way through it, but it is getting close to bed time.) I may have more comments the next time I review it.

I left some suggestions on the MR. @smustgrave, in #121 you said that you also commented on the MR, but I do not see those comments.

I am afraid that the MR also needs to be updated to resolve conflicts.

I am also not sure why this issue ever had the tag for subsystem maintainer review. Not every issue in the migration system needs that. Like most Drupal issues, it needs someone to write the code and someone to review it. In general, changing the status of an issue from NR to NW is not a good way to get the attention of the migration maintainers.

joachim’s picture

> ?AccountSwitcherInterface $account_switcher = NULL

$account_switcher should not be optional here.

It was optional for BC, but that handling was removed in f58fccc2fc690b62e1beac6a6d1c2b3d8a61c31a -- #3261004: Remove deprecated code from the migration system . The parameter should have been changed in that issue!

Fixing that here, but happy to cherry-pick it to a separate, blocking issue if preferred.

joachim’s picture

Status: Needs work » Needs review

I've addressed all the points in the review.

The MR is not letting me ticky things to say I've resolved them though :/

benjifisher’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

I replied to a few threads on the MR.

Since the MR adds a parameter to the constructor of EntityContentBase, this counts as an API change. This class is intended to be extended, so it cannot be final nor @internal.

The API change should be documented in the issue summary, under the "API changes" section. I am adding the tag for an issue summary update again.

We also need to deprecate calling the constructor without the new parameter. See the "Constructor parameter additions" section in Drupal deprecation policy.

joachim’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

Done.

quietone’s picture

I modified the test to use a mock migration and that lead to changing variable names and moving things around a bit. Also, some other minor changes and removed an item from the phpstan baseline. Curious that that was not discovered when running the commit checks locally.

benjifisher’s picture

Also ... removed an item from the phpstan baseline. Curious that that was not discovered when running the commit checks locally.

I think that difference is explained by this code block in commit-code-check.sh:

# Run PHPStan on all files on DrupalCI or when phpstan files are changed.
# APCu is disabled to ensure that the composer classmap is not corrupted.
if [[ $PHPSTAN_DIST_FILE_CHANGED == "1" ]] || [[ "$DRUPALCI" == "1" ]]; then
  printf "\nRunning PHPStan on *all* files.\n"
  php -d apc.enabled=0 -d apc.enable_cli=0 vendor/bin/phpstan analyze --no-progress --configuration="$TOP_LEVEL/core/phpstan.neon.dist"
else
  # Only run PHPStan on changed files locally.
  printf "\nRunning PHPStan on changed files.\n"
  php -d apc.enabled=0 -d apc.enable_cli=0 vendor/bin/phpstan analyze --no-progress --configuration="$TOP_LEVEL/core/phpstan-partial.neon" $ABS_FILES
fi
benjifisher’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record, +Needs followup

@quietone, thanks for working on this issue.

I made several suggestions on the MR. Most of them are minor, like adding the optional comma at the end of an argument list. If you feel strongly about using the plugin manager in the test class instead of the helper function, then I will not insist.

In #128, I wrote,

I had a look at the MR. (I got most of the way through it, but it is getting close to bed time.) I may have more comments the next time I review it.

I have now reviewed the entire MR.

We need a change record to document the API change, so I am adding the tag for that.

I am adding a tag for a follow-up issue because of the comment on core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php.

joachim’s picture

I think I've addressed all the comments apart from the ones about createDestination().

I tried adding a plugin ID to createDestination(), but then hit the problem that createDestination() uses the $this->storage property, and in the testFields() test we are using a different entity type.

I find createDestination() a bit problematic, as it's a mixture of taking parameters and reading properties, and updates a property rather than returning the destination object. For testFields() which sets up the a destination plugin multiple times, not explicitly seeing $destination being changed worsens readability.

> We need a change record to document the API change, so I am adding the tag for that.

I don't see why we need this. It's not an API change - the fields() method was there all along, just that EntityContentBase was failing to correctly implement it. If anything, this is a bugfix.

benjifisher’s picture

There are arguments on both sides of using createDestination() (previous two comments). As I said, I will not insist: we can agree to disagree. Still, from the MR comment:

createDestination() also hardcodes the entity type the destination is made with, because it uses $this->storage.

and

That will have the wrong entity storage.

I did run the test with the suggested changes. Probably it fails if you apply some but not all of them. But the basic pattern works:

    $this->storage = $entity_type_manager->getStorage('entity_test_with_bundle');
    $this->createDestination([]);
    $fields = $this->destination->fields();
I tried adding a plugin ID to createDestination(), ...

It turns out that is not needed. Just setting $this->storage is enough.


I don't see why we need this. It's not an API change - the fields() method was there all along, just that EntityContentBase was failing to correctly implement it. If anything, this is a bugfix.

It is both a bug-fix and an API change.

Custom or contrib modules may extend EntityContentBase, just as some of the core destination plugins do. If so, then those modules will need to add the new parameter, just as entity:comment and entity:user do in this MR.

Another way to put it: in order to fix the bug, this issue makes an API change.


Thanks for updating the MR. I do not have time now to re-review.

benjifisher’s picture

I did another round of review. Some of my earlier comments were not addressed, and I added a few new comments on the MR.

Let's make sure the PHPUnit tests pass.

joachim’s picture

Status: Needs work » Needs review

CR done and I think that's the rest of things fixed.

benjifisher’s picture

Thanks for the updates. This is very close: just one more @var comment should be nullable. (See the MR.)

Thanks for the CR. I added a line, and I am removing the issue tag.

Follow-up issues

I am removing these lines from the issue summary:

Make a follow up for the following, as it's a rarer case and more complicated to handle:

4. the migration's process mapping has the bundle field on the destination entity mapped from a constant value

In my opinion, that is a bad idea. The migration plugin knows about the destination plugin, and should pass configuration to it. The destination plugin should not know about the migration that is using it. Implementing this suggestion would add a lot of complexity to the system in order to make a small DX improvement when writing migrations. (See also Comments #86, #88, ...)

Thanks for adding #3474640: Drupal\Tests\migrate\Unit\destination\EntityRevisionTest uses weird mocking pattern. I am adding it as a related issue.

I added #3477244: Add return-type declaration to Drupal\migrate\Plugin\MigrateDestinationInterface::fields(), but I am not sure how we implement a change like this. If we just add a return-type declaration to the interface, then we will break any class that implements the interface and does not already have that declaration.

I am removing the issue tag for a folow-up.

joachim’s picture

Status: Needs work » Needs review

> In my opinion, that is a bad idea. The migration plugin knows about the destination plugin, and should pass configuration to it. The destination plugin should not know about the migration that is using it. Implementing this suggestion would add a lot of complexity to the system in order to make a small DX improvement when writing migrations. (See also Comments #86, #88, ...)

Yup, it would certainly add a lot of complexity. Fair enough that it's too much, and architecturally dubious, for a minor DX improvement.

I've applied your suggestion for the nullable type to the MR.

benjifisher’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for all the work on this, @quietone and @joachim! I think this issue is ready to go.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

benjifisher’s picture

Issue summary: View changes
Issue tags: +Novice

The MR no longer applied.

I rebased on the current 11.x, and the only conflict was in core/.phpstan-baseline.php. There is a single commit, removing one item from that file. The context (3 lines above and below the removed item) has changed, so that commit did not apply. During the rebase, I skipped that commit, then made the same change in a new commit.

Given the nature of the change, I feel I can do that and still keep my role as a reviewer of this issue.

Now that the merge conflict is resolved, PHPStan complains:

------ ------------------------------------------------------------------------
Line core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php
------ ------------------------------------------------------------------------
370 Method
Drupal\Tests\migrate\Kernel\MigrateEntityContentBaseTest::testFields()
has no return type specified.
------ ------------------------------------------------------------------------
[ERROR] Found 1 error

That should be easy to fix, but it is a little more than I should do as a reviewer. I am leaving the status at NW, and adding the Novice tag to add a return type to that function.

lavanyatalwar’s picture

Assigned: Unassigned » lavanyatalwar

Working on it.

lavanyatalwar’s picture

Heyy @benjifisher,
Fixed the missing return type issue.
Kindly check :)

lavanyatalwar’s picture

Assigned: lavanyatalwar » Unassigned
Status: Needs work » Needs review
benjifisher’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

@lavanyatalwar:

Thanks for fixing that. It may feel like a small thing, but helping to finish an issue that is 99% done has as much impact as completing an unstarted issue all by yourself.

Some unrelated tests were failing. That seems to happen a lot recently. Maybe I should add a note on #2829040: [meta] Known intermittent, random, and environment-specific test failures, but I was lazy and just re-ran the failing tests. They all pass, now.

Back to RTBC, The CI job and I agree that @lavanyatalwar correctly added the return type reported by PHPStan. I am updating the "Remaining tasks" in the issue summary and removing the Novice tag.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

benjifisher’s picture

Issue summary: View changes
Issue tags: +Novice

No good deed goes unpunished: our follow-up issue #3474640: Drupal\Tests\migrate\Unit\destination\EntityRevisionTest uses weird mocking pattern was recently Fixed, and it creates a conflict with this issue.

Resolving the conflict is a little more than what I am comfortable doing while acting as a reviewer on this issue. (I already did that once: see Comment #144. The changes now are a little more complicated.)

I rewrote the git history, combining all the commits that change core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php, and force-pushed. You can confirm that I only changed history by comparing with the tag for the previous HEAD of the feature branch:

$ git diff previous/2630732-11-x-migration-destinations-entity-fields/2024-11-05 && echo done
done

That should make it easier to rebase on the current 11.x. I think that is considered a Novice task, so I am adding that tag again.

When rebasing, pay attention to the improvements that #3474640 made to the other class variables:

  • Add a type declaration.
  • Call reveal() in the setUp() method, not the test/helper method(s).

baltowen made their first commit to this issue’s fork.

baltowen’s picture

Status: Needs work » Needs review
Issue tags: -Novice

Hi, I attempted to resolve the merge conflict, please review.

benjifisher’s picture

Status: Needs review » Needs work

@baltowen:

Thanks for working on this issue. Unfortunately, core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php fails after the changes you made. Back to NW.

There are also some unrelated tests that fail. For now, do not worry about those.

This issue adds the $entityTypeBundle class variable to the test class. After your rebase, that variable is handled correctly: call reveal() in the setUp() method, not in the test methods. But your rebase also changes the way $storage is handled. That is not in scope for this issue, and Comment #4 on #3474640: Drupal\Tests\migrate\Unit\destination\EntityRevisionTest uses weird mocking pattern explains why that one variable should not follow that pattern.

If you undo the changes to $storage in the test class, then that test should pass. Then we can worry about any unrelated test failures.

baltowen’s picture

Status: Needs work » Needs review

Thanks @benjifisher for the review. I have reverted the change of $storage.

benjifisher’s picture

Status: Needs review » Needs work

@baltowen:

Thanks for fixing that. There is still one line that needs to be fixed: see my comment on the MR. I wish I had caught that sooner.

There is also one unrelated test failure: Drupal\Tests\block\Functional\BlockCacheTest::testCachePerPage. Again, let's not worry about that until we fix the problem we know about.

baltowen’s picture

Status: Needs work » Needs review

Back to needs review.

benjifisher’s picture

@baltowen:

Thanks for fixing that.

Next time around, please add additional commits instead of making your changes as part of a rebase. I had to compare to the tag previous/2630732-11-x-migration-destinations-entity-fields/2024-11-05 in order to make sure that there were no accidental changes added during the rebase.

The merge conflicts were in core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php. I reviewed that carefully, and the changes there look good to me. Back to RTBC.

benjifisher’s picture

Status: Needs review » Reviewed & tested by the community
benjifisher’s picture

I forgot to review the failing tests:

  1. Drupal\Tests\image\Functional\ImageStylesPathAndUrlTest::testImageStyleUrlAndPathPrivate
  2. Drupal\Tests\responsive_image\FunctionalJavascript\ResponsiveImageFieldUiTest::testResponsiveImageFormatterUi

I added a note to #2829040: [meta] Known intermittent, random, and environment-specific test failures and re-ran the tests. They both passed.

liam morland made their first commit to this issue’s fork.

smulvih2’s picture

I was using 6111.diff as a patch in composer for core 10.3.6. Commits pushed in the last 1-2 days broke this and now it no longer applies. Here is a patch that captures all the latest changes and still applies to 10.3.x.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new129 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

liam morland’s picture

Status: Needs work » Reviewed & tested by the community

The bot is wrong; the patch is for Drupal 10.3.

larowlan’s picture

Status: Reviewed & tested by the community » Needs work

The deprecation links in the MR need to point to a change record, other than that there seems to still be a lot of open threads.
Can we get those resolved please? If the only change is to the deprecation link URLs, fine to self RTBC

I believe this one has required a few re-rolls so feel free to ping me for another look - thanks everyone

liam morland’s picture

I have updated the link to point to the change record.

benjifisher’s picture

I resolved several threads. I left open the ones where I made a suggestion and it has not been implemented. I still think these are improvements.

Unfortunately, one fix seems to have been lost, so back to NW. It is pretty small: just a missing |null in an @var comment.

liam morland’s picture

Status: Needs work » Needs review

I have rebased and fixed the missing comment mentioned in #166.

benjifisher’s picture

Status: Needs review » Reviewed & tested by the community

I reviewed all the changes, and I do not see anything else that got lost.

I still think it is a bad idea to cast to string in EntityContentBase::fields(), and some of my other suggestions would be improvements. But I will not insist on those changes, so RTBC.

smulvih2’s picture

Patch #161 not working with 10.4.x, which is supposed to be LTS for D10. Tested patch created from the merge request's latest commit ID 021da95f and works with 10.4.x, adding patch here.

quietone’s picture

Status: Reviewed & tested by the community » Needs work

The are conflicts in the phpstan baseline.

@smulvih2, Yes, Drupal 10 is an LTS, but not all changes will be backported. There is more detail on that at release overview page and the allowed changes in each version.

benjifisher’s picture

Status: Needs work » Reviewed & tested by the community

As in Comment #144, I think I can rebase and resolve the conflict in .phpatan-baseline.php even though I am the reviewer of this issue. Back to RTBC.

The conflict was caused by #3486713: Bump PHPStan to version 2.0.4, which changed the format of the baseline file.

heddn’s picture

Since Benji RTBCed this, I'm going to assume his suggestions/comments on the MR can be resolved at this point. That is now done. Otherwise, +1 on RTBC.

benjifisher’s picture

@heddn:

In Comment #166, I wrote,

I resolved several threads. I left open the ones where I made a suggestion and it has not been implemented. I still think these are improvements.

and in #168,

I still think it is a bad idea to cast to string in EntityContentBase::fields(), and some of my other suggestions would be improvements. But I will not insist on those changes, so RTBC.

I think you may have resolved some threads that I intentionally left open.

catch made their first commit to this issue’s fork.

catch’s picture

Status: Reviewed & tested by the community » Fixed

This all looks good. I had to update the deprecation message to reference 11.2.

Committed/pushed to 11.x, thanks!

  • catch committed 0c430949 on 11.x
    Issue #2630732 by joachim, mallezie, liam morland, joseph.olstad,...
catch’s picture

Status: Fixed » Closed (fixed)

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

web247 changed the visibility of the branch 10.3.x to hidden.

web247 changed the visibility of the branch 2630732-11-x-migration-destinations-entity-fields to active.