Problem/Motivation

The migration of the node title label generates a base_field_override config entity in Drupal 8 for every node type, even if its title label was not actually overridden in Drupal 7.

Proposed resolution

Change the migration to skip rows where the title label is 'Title' (the default).

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Status: Active » Postponed
Issue tags: +Needs tests
StatusFileSize
new6.36 KB

This appears to work fine. Notes:

wim leers’s picture

StatusFileSize
new6.1 KB

D'oh, this is the correct patch.

wim leers’s picture

Title: [PP-1] d7_node_title_label migration plugin should be derived per node type » [PP-1] d7_node_title_label migration plugin should be derived per node type AND should only be created for node types that have an override
Category: Task » Bug report
StatusFileSize
new1.73 KB
new6.65 KB
new172.44 KB

I also realized something more problematic still: right now, a base_field_override config entity is being created in Drupal 8 for every node type. Even if the title label was not customized in Drupal 7!

See https://git.drupalcode.org/project/drupal/blob/7.67/modules/node/node.mo... — the title label is set to Title by default. On wimleers.com, it's customized for only one node type, yet it was resulting in many config entities being created. Look at the title_label column in this screenshot of wimleers.com's node_type table:

The migration should be smarter; it should not create pointless configuration on the Drupal 8 destination site.

quietone’s picture

+++ b/core/modules/node/src/Plugin/migrate/source/d7/NodeType.php
@@ -33,7 +33,17 @@ class NodeType extends DrupalSqlBase {
+    if (isset($this->configuration['only_customized_title_labels'])) {
+      $query->condition('t.title_label', 'Title', '<>');
+    }

I understand the intention here, but let's not limit the source plugin like this. Normally, a source plugin gets all the data and the process plugin does the filtering. Yes, there are exceptions and prepareRows() do a lot of work in some cases. Instead, lets remove this and modify the pipeline in d7_node_title_label as needed.

wim leers’s picture

Thanks so much for the review! 😊

That's also what I thought first. But then I realized that if I do filtering in the process stage, that the "total count" (which is based on the source count) will always be inaccurate. We'd just end up skipping a lot of rows. I'd love to be told that I misunderstood the code though! Could you point me in the right direction? 🙏

The reason I believe this matters: it's very confusing to have N rows (or even N migrations) for this if we know for a fact that only 1 row (or 1 migration) actually contains data to be migrated, because only one Node Type has had its title label customized. (If this explanation isn't clear enough, I'm happy to explain in more detail, with annotated screenshots.)

wim leers’s picture

quietone’s picture

Status: Postponed » Needs review
StatusFileSize
new1.95 KB

Rereading this again and it seems that the problem is that base_field_overrides are created for every content type when it only needs to be created when the title field is, in fact, overridden. (If I understood that correctly then the IS needs an updated.) And that can be tested if the field label is not 'Title'. A deriver is not needed to do that, as the attached patch shows.

The total rows returned by the source plugin will be equal to the number of content types. We want the source plugin to make available all the data to the pipeline, which is where decisions are made. I understand the desire to change the source plugin to get 'just the data we want' as I have done that on several occasions for some of the i18n source plugins and each time I get feedback that the source plugin needs to get all the data. Plus, in this case we are not changing a source plugin which would then require changing the test.

Changing to NR to run tests.

Status: Needs review » Needs work

The last submitted patch, 8: 3097327-8.patch, failed testing. View results

meenakshig’s picture

Status: Needs work » Needs review
StatusFileSize
new2.53 KB
new428 bytes
wim leers’s picture

quietone’s picture

Title: [PP-1] d7_node_title_label migration plugin should be derived per node type AND should only be created for node types that have an override » d7_node_title_label migration plugin should be derived per node type AND should only be created for node types that have an override
Issue summary: View changes
Issue tags: -Needs tests

I don't think this needs to be postponed. And the test has been updated to test the change to the migration.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Since this patch now looks completely different than the one I posted in #3, and it still solves the problem … I'm gonna be bold and RTBC this :)

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

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

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

heddn’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs title update, +Needs issue summary update

Minor point, but an update IS and title would be appropriate at this point. Let's go back to NW for those small fixes.

wim leers’s picture

Title: d7_node_title_label migration plugin should be derived per node type AND should only be created for node types that have an override » d7_node_title_label migration plugin incorrectly generating base_field_override for every node type, even those that don't have an overridden title label
Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs title update, -Needs issue summary update
heddn’s picture

+1 on RTBC. IS and title make a lot more sense now given what is in the patch.

wim leers’s picture

Great! :) Thanks for the guidance, @heddn and especially @quietone! Much appreciated 🙏

webchick’s picture

Status: Reviewed & tested by the community » Needs review

These comments might be out of step with The Way In Which Things Are Done™ in the migrate system, so only setting down to "Needs review" vs. "needs work"... nevertheless, these were my impressions:

-      'base_field_override' => 9,
+      'base_field_override' => 4,

What's the significance of this change? Could we maybe leave a comment behind, so this doesn't accidentally get reordered in the future, which breaks this behaviour again?

+    // Other content type should not have a base_field_override.
+    $no_override_node_type = [
+      'article',
+      'blog',
+      'book',
+      'page',
+      'test_content_type',
+    ];
+    foreach ($no_override_node_type as $type) {
+      $override = BaseFieldOverride::load("node.$type.title");
+      $this->assertFalse($override instanceof BaseFieldOverride);
+    }

Nitpick: "types"

This does not seem to be reflective though of the use case brought by Wim. Wim had one content type in the database which was doing a title override. The remainder were not. Could we expand the comments here, like:

// Forum title labels are overridden to "Subject"; verify that this change made it over okay.

...

// The remainder are just using the default of "Title", so we should expect configuration to be skipped on the new site.

...or something like that?

wim leers’s picture

What's the significance of this change? Could we maybe leave a comment behind, so this doesn't accidentally get reordered in the future, which breaks this behaviour again?

That's in \Drupal\Tests\migrate_drupal_ui\Functional\d7\Upgrade7Test::getEntityCounts(). The documentation for that method says it all:

  /**
   * Gets the expected number of entities per entity type after migration.
   *
   * @return int[]
   *   An array of expected counts keyed by entity type ID.
   */

+1 to the other remarks @webchick posted :)

quietone’s picture

Status: Needs review » Needs work

NW to update the comments.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new625 bytes
new2.6 KB

Updating comments. Oddly, the patch didn't apply for me so there is a diff not interdiff. The patch failed on /core/modules/migrate_drupal_ui/tests/src/Functional/d7/Upgrade7Test.php.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

  • webchick committed c2ea8a5 on 9.0.x
    Issue #3097327 by Wim Leers, quietone, Meenakshi.g: d7_node_title_label...

  • webchick committed 5dc210e on 8.9.x
    Issue #3097327 by Wim Leers, quietone, Meenakshi.g: d7_node_title_label...

  • webchick committed f9403e0 on 8.8.x
    Issue #3097327 by Wim Leers, quietone, Meenakshi.g: d7_node_title_label...
webchick’s picture

Version: 8.9.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Fixed

I ideally wanted a bit more "why" there but quietone out-voted me, so we'll go with this, which is certainly better than the status quo. :)

Committed and pushed to 9.0.x; 8.9.x; 8.8.x. Thanks!

Status: Fixed » Closed (fixed)

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