Problem/Motivation
A full migration test of Ubercart 7 to Commerce using the UI (commerce_migrate) is failing because d7_rdf_mapping reports errors if the rdf mapping already exists. Reporting errors if the entity exists doesn't happen in other migrations and let's not do it here.
$ drush mim d7_rdf_mapping
[error] 'rdf_mapping' entity with ID 'node.article' already exists. (/opt/sites/d8/core/lib/Drupal/Core/Entity/EntityStorageBase.php:462)
[error] 'rdf_mapping' entity with ID 'node.page' already exists. (/opt/sites/d8/core/lib/Drupal/Core/Entity/EntityStorageBase.php:462)
[notice] Processed 2 items (0 created, 0 updated, 2 failed, 0 ignored) in 1.8 seconds (66.8/min) - done with 'd7_rdf_mapping'
Tracked this to Entity::getEntity() where the entity_id is obtained from the row and then the entity is checked to see if it exists. If it does not exist it will be attempt to create storage and I think that is where the error occurs. Suffice it to save that the entity id should be on the row for getEntity() to check if it exists.
When that was fixed I was getting the following error on loading an node of type article.
1) Drupal\Tests\migrate_drupal_ui\Functional\d7\MigrateUpgrade7Test::testMigrateUpgradeExecute
Exception: Warning: date() expects parameter 2 to be integer, array given
date_iso8601()() (Line: 343)Investigating that led to the discovery that RDF uses a different method for handling dates not, date_iso8601, which is what is migrated. That need to be changed to Drupal\rdf\CommonDataConverter::dateIso8601Value.
Proposed resolution
Add an id property to the d7_rdf_mapping so that Entity::getEntity() has an id value to use to check if the entity already exists.
Add a static_map to convert the callback 'date_iso8601' to 'Drupal\rdf\CommonDataConverter::dateIso8601Value'.
Remaining tasks
Patch, there is a fail patch as well.
Review
Commit
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | interdiff.txt | 4.1 KB | quietone |
| #12 | 2998666-12.patch | 5.92 KB | quietone |
| #10 | interdiff.txt | 662 bytes | quietone |
| #10 | 2998666-10.patch | 2.17 KB | quietone |
| #3 | 2998666-3.patch | 1.16 KB | quietone |
Comments
Comment #2
quietone commentedUsing this patch the contrib test passes. Deliberately not running the testbot, wait until there is a test.
Comment #3
quietone commentedAdded a test and a fail test. After the rdf migration test is run the migrate map is destroyed and then the rdf migration is run again to show that it works with pre existing rdf mappings.
No interdiff because these are small files.
Comment #6
quietone commentedNot sure why the patch is failing on
1) Drupal\Tests\migrate_drupal_ui\Functional\d7\MigrateUpgrade7Test::testMigrateUpgradeExecute
Exception: Warning: date() expects parameter 2 to be integer, array given
date_iso8601()() (Line: 343)
Anyone have an idea?
Comment #7
quietone commentedI came across this post about getting warnings after upgrading
https://www.drupal.org/forum/support/upgrading-drupal/2018-09-18/warning...
which is the same error. Changing to Major.
The workaround it most likely to remove the rdf mappings from the site configuration. At least that is what worked locally in my test environment.
edit: the same error meaning the same error as the test for the patch in #3
Comment #8
quietone commentedImprove the title
Comment #9
quietone commentedI've been trying to figure this out tonight.
By searching I found this https://www.drupal.org/project/drupal/issues/1784234 which gave some context and background. And since I don't know RDF, that was helpful. That got me to look at the mappings in core, specifically core/profiles/standard/config/install/rdf.mapping.node.article.yml because I'm testing with article type.
It was obvious straight away that the rdf.mapping.node.article is using a different callback from the migrated one for the date fields. And that callback, CommonDataConverter, expects the input to be an array, whereas date_iso8601 expects a string which is what is causing the warning.
I made a test by just editing the article mapping to change the date callbacks and then didn't get any warnings when loading articles. No time to make a patch, tonight.
needs to be changed to
Comment #10
quietone commentedThis adds a static_map in the process to accomplish the suggestions in #9. Locally, that fixed the error.
Comment #12
quietone commentedHah, I completely forgot to update the rdf migation test.
Comment #13
quietone commentedComment #14
heddnSo, I applied the patch and after doing that, things are lot more clear. The yaml looking here is not from a migration yaml. It is the configuration of rdf. And it actually does expect a class name in the configuration. And that configuration should be this updated format.
And with that and passing tests, this can be RTBC.
Comment #16
catchCommitted and pushed 68773eb705 to 8.7.x and 201bcb1007 to 8.6.x. Thanks!