Problem/Motivation

Some of Migrate’s cckfield plugin's method naming are not describing clear enough what they do and therefore may confuse developers using the API (therefore giving poor DX).

Proposed resolution

See discussion in #23 - #27

  • Rename processFieldValues() to defineValueProcessPipeline()
  • Rename processField() to alterFieldMigration()/li>
  • Rename processFieldInstance() to alterFieldInstanceMigration()
  • Rename processFieldWidget() to alterFieldWidgetMigration()
  • Rename processFieldFormatter() to alterFieldFormatterMigration()
  • Update tests
  • Add BC layer

Remaining tasks

Review
Commit

User interface changes

None.

API changes

Yes.

  1. processCckFieldValues() will be deprecatedThis wad deprecated in #2683435: CCK does not exist in Drupal 7, rename Migrate's cckfield plugins to field plugins
  2. processFieldValues() will be deprecated
  3. processField() will be deprecated
  4. processFieldInstance() will be deprecated
  5. processFieldWidget() will be deprecated
  6. processFieldFormatter() will be deprecated

Data model changes

None.

Original report

Those who know me know that I’m fairly fanatical about good DX in core APIs (or, indeed, any APIs). Because of that, certain aspects of Migrate’s cckfield plugins have been bugging me for a long time.

I have three main bones to pick:

  1. processField() is poorly named. Its actual purpose is altering the migrations that transform CCK fields (in D6) and Field API field definitions (in D7) into D8 field_storage_config entities. This should be renamed to processFieldMigration() or alterFieldMigration().
  2. processFieldInstance() has the same problem. It should be called processFieldInstanceMigration() or alterFieldInstanceMigration().
  3. processCckFieldValues() is on another planet entirely. Its purpose is to define the processing pipeline for values of the field type that the plugin handles, but this does not come through at all in the method name. I think this should be called something like defineFieldValueProcess() or defineValueProcessPipline().

The doc blocks for each of these methods in MigrateCckFieldInterface need to be improved as well. These plugins are crucial for contrib migrations from D6 and D7, so the interface should include short snippets of example code in the doc comments.

CommentFileSizeAuthor
#134 2631698-134.patch5.5 KBphenaproxima
#132 2631698-132.patch5.51 KBphenaproxima
#131 2631698-131.patch7.04 KBphenaproxima
#121 2631698-121.patch1.49 KBheddn
#119 2631698-119.patch1.02 KBheddn
#103 2631698-103.patch60.95 KBjofitz
#103 interdiff-2631698-95-103.txt1.67 KBjofitz
#95 2631698-95.patch60.2 KBjofitz
#91 2631698-91.patch60.56 KByogeshmpawar
#87 2631698-87.patch60.03 KBjofitz
#87 interdiff-82-87.txt815 bytesjofitz
#82 2631698-82.patch60.2 KBjofitz
#82 interdiff-80-82.txt548 bytesjofitz
#80 2631698-80.patch60.02 KBjofitz
#80 interdiff-78-80.txt761 bytesjofitz
#78 2631698-78.patch59.27 KBjofitz
#78 interdiff-74-78.txt5.38 KBjofitz
#78 interdiff-63-78.txt11.95 KBjofitz
#76 2631698-74.patch57.41 KBrobpowell
#74 interdiff-71-74.txt4.01 KBrobpowell
#71 2631698-71.patch58.82 KBrobpowell
#63 interdiff-57-64.txt4.64 KBrobpowell
#63 2631698-63.patch59.02 KBrobpowell
#57 interdiff-54-57.txt801 bytesrobpowell
#57 2631698-57.patch58.58 KBrobpowell
#54 interdiff-2631698-51-54.txt2.66 KBphenaproxima
#54 2631698-54.patch58.72 KBphenaproxima
#51 2631698-51.patch58.28 KBphenaproxima
#49 interdiff-2631698-44-49.txt12.01 KBrobpowell
#49 2631698-49.patch50.65 KBrobpowell
#45 interdiff-2631698-38-44.txt4.11 KBrobpowell
#44 2631698-44.patch50.48 KBrobpowell
#38 2631698-38.patch50.2 KBjofitz
#30 2631698-30.patch50.19 KBjofitz
#30 interdiff-28-30.txt18.16 KBjofitz
#28 2631698-28.patch45.83 KBjofitz
#28 interdiff-25-28.txt33.62 KBjofitz
#25 2631698-25.patch13.12 KBjofitz
#25 interdiff-23-25.txt15.3 KBjofitz
#23 2631698-23.patch13 KBjofitz

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Issue summary: View changes
benjy’s picture

Yeah I think we can do better here as well, I think the process in processField initially came about because we are updating the "process" array for the field.

Anyway, I like the alter* method suggestions in the summary, I think alter is a better word since we're altering the migration not the actual data.

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

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now 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

mikeryan’s picture

Status: Active » Postponed

As with #2683435: CCK does not exist in Drupal 7, rename Migrate's cckfield plugins to field plugins, renaming stuff would disrupt the patch for #2631736: Cckfield Plugins must distinguish core versions, which is both more important and close to RTBC - let's postpone considering this until that is in.

mikeryan’s picture

Status: Postponed » Active

Unblocked.

phenaproxima’s picture

Status: Active » Postponed

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.

mikeryan’s picture

Issue tags: -Migrate BC break

If I'm not mistaken, these would all be simple renames and easily covered by a BC layer passing through to the new names, so not really a BC break.

phenaproxima’s picture

Status: Postponed » Active

Unblocked!

mikeryan’s picture

Status: Active » Postponed

Rename patch was reverted.

heddn’s picture

Issue tags: +Migrate BC break
heddn’s picture

Issue tags: -Migrate BC break

This can be done with a BC shim layer, so removing the BC break tag.

imiksu’s picture

Issue summary: View changes

Changes:

  • Updated summary
  • Given that benjy in #3 liked the alter* versions more, I've picked them as clear tasks
  • The third method name is still up to decide or are open to other suggestions is the final task before
  • Added task for updating automatic tests (right?)
  • Added task Provide BC layer, if doesn't land to 8.2.x (right?)

What needs more information

  • I would like to know how we wont break BC if it doesn't land to 8.2.x?

EDIT: Whoops completely forgot 8.2 was released, lol :)

imiksu’s picture

imiksu’s picture

Issue summary: View changes

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.

jofitz’s picture

Status: Postponed » Active

No longer blocked.

quietone’s picture

Issue summary: View changes

What about proccessFieldWidget() and processFieldFormatter()?

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.

jofitz’s picture

Status: Active » Needs review
StatusFileSize
new13 KB

WIP. Before I go too far can someone confirm that I am doing the right thing, please?

So far I have:

  • replaced processFieldValues() with defineFieldValueProcess()
  • set processFieldValues() as deprecated in all classes that used it (but not the interface).
heddn’s picture

Title: Fix sub-optimal DX in MigrateCckFieldInterface » Fix sub-optimal DX in MigrateFieldInterface

I liked defineValueProcessPipline from the IS better.

jofitz’s picture

StatusFileSize
new15.3 KB
new13.12 KB

Changed defineFieldValueProcess() to defineValueProcessPipeline(). Otherwise am I on the right track? Shall I do similar for processField() and processFieldInstance()? What about proccessFieldWidget() and processFieldFormatter()?

quietone’s picture

Yea, I think this is the right track.

What about proccessFieldWidget() and processFieldFormatter()?

I too was wondering about that. Both are doing a $migration->mergeProcessOfProperty('options/type', $process); so they seem like a good candidate for renaming, by replacing process with alter. It makes sense to me, at least.

phenaproxima’s picture

Status: Needs review » Needs work

...they seem like a good candidate for renaming, by replacing process with alter

I agree. Let's do this. How about names like alterFieldInstanceMigration()?

jofitz’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new33.62 KB
new45.83 KB

Updated IS.

Renamed instances of:

  • processField()
  • processFieldInstance()
  • processFieldWidget()
  • processFieldFormatter()
heddn’s picture

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

The BC layer still needs tests.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new18.16 KB
new50.19 KB

Retained previous tests for BC.

While making the changes I noticed that:
modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php
and
modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php
are almost identical. Is there any need for both? I realise that is not within the scope of this issue, but is it worth creating a new issue to remove one or the other?

quietone’s picture

The issue of the 'duplicate' test files d6/TextFieldTest.php seems to apply to the d7 versions as well. And it looks like I separated the test into two versions in #2833206: Convert Migrate's cckfield plugins to use the new field plugins in #70

(8.5.x)$ diff Migrate/d6/TextFieldTest.php Plugin/migrate/field/d6/TextFieldTest.php 
3c3
< namespace Drupal\Tests\text\Unit\Migrate\d6;
<code>---
> namespace Drupal\Tests\text\Unit\Plugin\migrate\field\d6;
14d13
<  * @group legacy
v@cm {/opt/sites/d8/core/modules/text/tests/src/Unit} (8.5.x)$ diff Migrate/d7/TextFieldTest.php Plugin/migrate/field/d7/TextFieldTest.php 
3c3
< namespace Drupal\Tests\text\Unit\Migrate\d7;
---
> namespace Drupal\Tests\text\Unit\Plugin\migrate\field\d7;
5c5
< use Drupal\Tests\text\Unit\Migrate\d6\TextFieldTest as D6TextFieldTest;
---
> use Drupal\Tests\text\Unit\Plugin\migrate\field\d6\TextFieldTest as D6TextFieldTest;
10d9
<  * @group legacy

Seems like a separate issue to me, but it is late and I should be asleep...

heddn’s picture

We could also update the IS with the proposed renames? That would make this easier to review.

jofitz’s picture

@heddn the proposed renames are in the "Remaining tasks" section.

quietone’s picture

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

Updated the IS.

quietone’s picture

Issue summary: View changes

Update the remaining tasks.

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.

heddn’s picture

Assigned: Unassigned » heddn
Status: Needs review » Needs work
Issue tags: +Needs reroll

I think this is pretty close. But let's re-roll it again first.

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new50.2 KB

Re-roll.

Status: Needs review » Needs work

The last submitted patch, 38: 2631698-38.patch, failed testing. View results

heddn’s picture

Issue tags: +Novice

Looks like a rename of iterator => sub_process is in order here. Tagging Novice.

robpowell’s picture

I am working on this as part of SprintWeekend2018.

phenaproxima’s picture

Issue tags: +SprintWeekend2018
robpowell’s picture

Issue tags: +SprintWeekendBOS
robpowell’s picture

StatusFileSize
new50.48 KB
robpowell’s picture

StatusFileSize
new4.11 KB

here's the interdiff

robpowell’s picture

Status: Needs work » Needs review
phenaproxima’s picture

Status: Needs review » Needs work

Looks great. Thank you, @robpowell!

Unfortunately, I think this still needs some work, mostly to bring it in line with the core deprecation policy.

  1. +++ b/core/lib/Drupal/Core/Field/Plugin/migrate/field/Email.php
    @@ -40,9 +40,17 @@ public function getFieldFormatterMap() {
       public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
    +    return $this->defineValueProcessPipeline($migration, $field_name, $data);
    +  }
    

    As per the deprecation policy, let's always add a @trigger_error() call before calling defineValueProcessPipeline() from processFieldValues().

  2. +++ b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php
    @@ -29,6 +29,10 @@ public function testUnknownDateType() {
    +    $this->plugin->defineValueProcessPipeline($this->migration, 'field_date', ['type' => 'timestamp']);
    +
    +    // Retain backwards compatibility testing.
    +    $this->setExpectedException(MigrateException::class, "Field field_date of type 'timestamp' is an unknown date field type.");
    

    This won't work, because the test method will exit as soon as defineValueProcessPipeline() throws its expected exception. I think we will have to copy this entire test method, and in the copy we'll call processFieldValues(). Those cloned methods should also mention in their doc comment that they are testing backwards compatibility and should be removed.

  3. +++ b/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php
    @@ -38,9 +38,14 @@ public function getFieldWidgetMap() {
       public function processFieldInstance(MigrationInterface $migration) {
    +    $this->alterFieldInstanceMigration($migration);
    +  }
    

    We also need to do the proper @trigger_error() thing here too.

robpowell’s picture

Spoke to @phenaproxima, processFieldValues() is being inherited by FieldPluginBase.php. We can make the change recommended in #47.1 in FieldPluginBase::processFieldValues() and remove the child class declarations of processFieldValues().

robpowell’s picture

StatusFileSize
new50.65 KB
new12.01 KB

Went ahead and followed the same cleanup for four depracated methods, here's the total list:

  • processField()
  • processFieldInstance()
  • processFieldWidget()
  • processFieldFormatter()
  • processFieldValues()

#47.2 This was the case in field/fieldDateTest.php and d6/fieldDateTest.php. To complete the requirements of the deprecation policy,

A unit test proving the deprecation notice will be triggered when the deprecated code is called.

#47.3 done

robpowell’s picture

Status: Needs work » Needs review
phenaproxima’s picture

StatusFileSize
new58.28 KB

I've taken the fine work @robpowell did and tweaked it a bit.

The main thing here is that, rather than repeat entire test methods just to call a single deprecated method, I've created separate test classes to exercise the deprecated methods and assert that the proper deprecation errors are raised.

No interdiff because the changes are complex enough that it will be easier to parse this cleanly.

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

Status: Needs review » Needs work

The last submitted patch, 51: 2631698-51.patch, failed testing. View results

phenaproxima’s picture

Status: Needs work » Needs review
StatusFileSize
new58.72 KB
new2.66 KB

Let's try that again.

phenaproxima’s picture

Issue tags: -Novice

Also removing the Novice tag, because I no longer think it applies.

Status: Needs review » Needs work

The last submitted patch, 54: 2631698-54.patch, failed testing. View results

robpowell’s picture

StatusFileSize
new58.58 KB
new801 bytes
+++ b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/cckfield/TaxonomyTermReferenceCckTest.php
@@ -45,10 +45,17 @@ protected function setUp() {
+   * @expectedDeprecation TaxonomyTermReference is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\taxonomy\Plugin\migrate\field\TaxonomyTermReference instead.

`processCckFieldValues` does not return expectedDepraction removing it passes tests locally.

robpowell’s picture

Status: Needs work » Needs review
heddn’s picture

Status: Needs review » Reviewed & tested by the community

Lots of changes are in place. Tests are passing. FieldPluginBase has deprecation triggers in place, so we can be pretty sure we caught all re-names. If we didn't, then we can grab them in follow-ups. I'm good with RTBC, as I don't see any issues in here.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

We need a change record here and all the deprecation notices should be pointing to it as per https://www.drupal.org/core/deprecation

I'm not 100% convinced we should be removing stuff from the interface. However of course things are still implemented by the base classes that everyone would extend so that's good. Love the deprecation work and testing - really good to have all the testing still in place. However I think that there might be a problem. For example, Example module has a migrate field plugin that implements \Drupal\migrate_drupal\Plugin\MigrateFieldInterface::processFieldValues how would it ever be called by node derivers?

robpowell’s picture

I'll take care of this tonight

#60 .1

We need a change record here and all the deprecation notices should be pointing to it as per https://www.drupal.org/core/deprecation
robpowell’s picture

Assigned: heddn » robpowell
robpowell’s picture

StatusFileSize
new59.02 KB
new4.64 KB

Alright, should be all set now.

robpowell’s picture

Status: Needs work » Needs review
robpowell’s picture

If someone could also review the change record, that would be great #2944598: Update method names to be more meaningful in MigrateFieldInterface

Status: Needs review » Needs work

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

heddn’s picture

Issue tags: -Needs change record +Novice

Looks like this is just updating the tests to account for the link to the change record. Or am I wrong? Tagging novice for that. And removing the CR tag as we already seem to have a CR.

heddn’s picture

Assigned: robpowell » Unassigned

Unassigning since this seems like anyone could pick up the novice tasks.

robpowell’s picture

@heddn, I can fix the failed errors if someone will weigh in on the syntax change of the error message. I believe when I picked this up the error message was :

Deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use defineValueProcessPipeline() instead.

per the example on https://www.drupal.org/core/deprecation, I saw that the versions ended in .0 so I went ahead and updated that without being 100% clear if that was the right step forward. Here is an example of what an error message looks like now (with the change record link):

Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.

See how the versions changed from 8.5.x to 8.6.0 and 9.0.x to 9.0.0, is that OK?

heddn’s picture

Changing the version is correct. Because 8.5.0 was already released. And API changes to interfaces should occur in minor releases. Not point releases within a minor.

robpowell’s picture

StatusFileSize
new58.82 KB

I removed the changes to file d7/ImageField.php because issue 2934145 changed this file and it looks like the change in this ticket is no longer needed:

+++ b/core/modules/file/src/Plugin/migrate/field/d7/ImageField.php
@@ -18,7 +18,7 @@ class ImageField extends FieldPluginBase {
   /**
    * {@inheritdoc}
    */
-  public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
+  public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
     $process = [
       'plugin' => 'sub_process',
       'source' => $field_name,
robpowell’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 71: 2631698-71.patch, failed testing. View results

robpowell’s picture

StatusFileSize
new4.01 KB

This should fix the file.file and text.text failures. I ended up removing the changes introduced by this patch to ImageFieldTest.php because of the changes in issue 2934145

+++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldLegacyTest.php
--- a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php
+++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php

+++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php
@@ -31,7 +31,7 @@ protected function setUp() {
 
     $migration = $this->prophesize(MigrationInterface::class);
 
-    // The plugin's processFieldValues() method will call
+    // The plugin's defineValueProcessPipeline() method will call
     // mergeProcessOfProperty() and return nothing. So, in order to examine the
     // process pipeline created by the plugin, we need to ensure that
     // getProcess() always returns the last input to mergeProcessOfProperty().
@@ -43,10 +43,10 @@ protected function setUp() {

@@ -43,10 +43,10 @@ protected function setUp() {
   }
 
   /**
-   * @covers ::processFieldValues
+   * @covers ::defineValueProcessPipeline
    */
-  public function testProcessFieldValues() {
-    $this->plugin->processFieldValues($this->migration, 'somefieldname', []);
+  public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') {
+    $this->plugin->$method($this->migration, 'somefieldname', []);
robpowell’s picture

Status: Needs work » Needs review
robpowell’s picture

StatusFileSize
new57.41 KB

Status: Needs review » Needs work

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

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new11.95 KB
new5.38 KB
new59.27 KB

I'm worried that this is beginning to wander away from the point. Here's my take on it, based on the patch in #63, but also with an interdiff against #74.

Status: Needs review » Needs work

The last submitted patch, 78: 2631698-78.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Novice
StatusFileSize
new761 bytes
new60.02 KB

Add @expectedDeprecation to fix final test failure.

Status: Needs review » Needs work

The last submitted patch, 80: 2631698-80.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new548 bytes
new60.2 KB

Nearly there...

robpowell’s picture

@Jo Fitzgerald thanks for picking this up, I too was concerned that I was removing too much. The multiple interdiffs really helped me review the changes you made vs my changes.

If possible, can you summarize in laymen terms what your patches do? I hit a lot of problems trying to wrap my head around the changes to d7/ImageFieldTest.php due to the other issue and how I should implement this patch on top of it. Can you speak to how you knew what to do here?

+++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php
@@ -44,11 +44,11 @@ protected function setUp() {
-  public function testProcessFieldValues() {
-    $this->plugin->processFieldValues($this->migration, 'somefieldname', []);
+  public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') {
+    $this->plugin->$method($this->migration, 'somefieldname', []);
heddn’s picture

+++ b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldTest.php
@@ -13,24 +14,28 @@
+   * @expectedDeprecation DateField is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\datetime\Plugin\migrate\field\DateField instead.
    */
-  public function testUnknownDateType() {
...
     $this->setExpectedException(MigrateException::class, "Field field_date of type 'timestamp' is an unknown date field type.");

This seems strange. All the rest of the deprecations are about 8.6. What's this about?

I also reviewed the CR. It looks pretty nice. Almost there, only the question here before RTBC.

jofitz’s picture

@heddn I'm not convinced it is relevant to this patch, it covers the @trigger_error() in Drupal\datetime\Plugin\migrate\field\d6\DateField. Shall I remove it?

heddn’s picture

Remove it, but if we need that test coverage, we should open a follow-up.

jofitz’s picture

StatusFileSize
new815 bytes
new60.03 KB

Removed out of scope test. Added follow-up to add the removed test: #2960056: Add deprecation test to d6/DateField

heddn’s picture

Status: Needs review » Reviewed & tested by the community

That was my only concern. So onto RTBC. We've got a CR, we've got docs and tests and deprecation notices and @see links to the CR.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 87: 2631698-87.patch, failed testing. View results

yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar
yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
Status: Needs work » Needs review
StatusFileSize
new60.56 KB

#87 failed to apply on 8.6.x branch, so i have rerolled the patch.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Diff stats are the same. Back to RTBC.

heddn’s picture

Discussed in the migrate maintainers meeting today with alexpott, phenaproxima, heddn, maxocub, quieone. In summary, we all think the BC test layer is good. The consensus though it we don't want to do another CCK => field plugin rename here and cause a lot of heartache for folks. On the flip-side, the current method names are so dense and obtuse, there is much less adoption (outside of core fields) than we'd like to see. Contrib isn't using field plugins that much. And custom migrations have even less adoption. By renaming, we can actually provide some good tutorials and docs that are intuitive. And hopefully make it much easier for folks to use these things.

Still leaving in RTBC while we think about it.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 91: 2631698-91.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new60.2 KB

Re-roll.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Diff stats identical. Back to RTBC.

quietone’s picture

Working with fields will be less confusing when we can use these descriptive method names. No more having to take a extra time to recall what the 'process' really does, the method name will tell you!

Status: Reviewed & tested by the community » Needs work

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

phenaproxima’s picture

Status: Needs work » Reviewed & tested by the community

Because this is an API addition, we should try to land it for 8.6.0. There's no reason we can't go back to RTBC here once Drupal CI passes, which I expect it will.

Although I also don't want to go through another "let's rename the things" nightmare either, I think this has pretty decent explicit test coverage, in that we're executing and confirming all the deprecations. I feel like we've meditated on this one long enough, and with the 8.6.0 alpha deadline approaching, it's decision time. Seeing as how this is a major DX win -- the method names we are deprecating would never have landed in core to begin with if they were being introduced in this patch -- I think the benefits outweigh the risks. So, as one of the subsystem maintainers, I vote we go ahead here.

heddn’s picture

For all the same reasons #99, +1 from me.

Status: Reviewed & tested by the community » Needs work

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

phenaproxima’s picture

Issue tags: +Needs reroll

I think we need a reroll here to account for recently-committed changes.

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new1.67 KB
new60.95 KB
  1. Make correction to code that was triggering deprecation errors.
  2. Fix a couple of coding standards errors.
phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! RTBC on the assumption that all backends will pass tests.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 103: 2631698-103.patch, failed testing. View results

phenaproxima’s picture

Status: Needs work » Reviewed & tested by the community

Wat? Methinks that is a testbot hiccup.

  • catch committed 14a769b on 8.6.x
    Issue #2631698 by Jo Fitzgerald, robpowell, phenaproxima, heddn,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

I was also iffy on removing things from the interface here, but given migrate_drupal isn't stable yet, I think I agree with @alexpott's #60 "However of course things are still implemented by the base classes that everyone would extend so that's good." Just noting this here so it's clear what the decision was if it comes back to bite us.

The only people who could get in trouble would be people calling the classes implementing the interface directly, but in this case we don't expect people to do that, we expect most people to implement it, or just use the classes indirectly via the migrate system. And for people implementing the interfaces, having the deprecated methods isn't helpful at all.

So. Committed 14a769b and pushed to 8.6.x. Thanks!

neclimdul’s picture

Status: Fixed » Needs work

The tests added here broke phpunit.

There were 2 failures:

1) Drupal\Tests\file\Unit\Plugin\migrate\field\d7\ImageFieldTest::testDefineValueProcessPipeline
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
 @expectedDeprecation:
-%A  ImageField is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.x. Use \Drupal\image\Plugin\migrate\field\d7\ImageField instead. See https://www.drupal.org/node/2936061.
+

2) Drupal\Tests\datetime\Unit\Plugin\migrate\field\d6\DateFieldTest::testUnknownDateType
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
 @expectedDeprecation:
-%A  DateField is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\datetime\Plugin\migrate\field\DateField instead.
+

FAILURES!
Tests: 18512, Assertions: 29460, Failures: 2, Skipped: 2273, Incomplete: 1.

Legacy deprecation notices (71)
quietone’s picture

@neclimdul, I can't reproduce those errors, those tests pass for me locally.

neclimdul’s picture

Easy enough to reproduce. Try this:

git clone --branch 8.6.x https://git.drupal.org/project/drupal.git
cd drupal
composer install
composer run-script drupal-phpunit-upgrade # optional depending on php version.
./vendor/bin/phpunit -c core/phpunit.xml.dist --testsuite unit
heddn’s picture

I cannot reproduce either.

$ vendor/bin/phpunit -c core core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php
PHPUnit 6.5.9 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\file\Unit\Plugin\migrate\field\d7\ImageFieldTest
.                                                                   1 / 1 (100%)

Time: 1.05 seconds, Memory: 6.00MB

OK (1 test, 2 assertions)


$ vendor/bin/phpunit -c core core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldTest.php
PHPUnit 6.5.9 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\datetime\Unit\Plugin\migrate\field\d6\DateFieldTest
.                                                                   1 / 1 (100%)

Time: 254 ms, Memory: 6.00MB

OK (1 test, 3 assertions)

neclimdul’s picture

try ./vendor/bin/phpunit -c core/phpunit.xml.dist --testsuite unit as noted in #111

quietone’s picture

Using the steps in #11 I got two failures.

There were 2 failures:

1) Drupal\Tests\file\Unit\Plugin\migrate\field\d7\ImageFieldTest::testDefineValueProcessPipeline
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
 @expectedDeprecation:
-%A  ImageField is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.x. Use \Drupal\image\Plugin\migrate\field\d7\ImageField instead. See https://www.drupal.org/node/2936061.
+

2) Drupal\Tests\datetime\Unit\Plugin\migrate\field\d6\DateFieldTest::testUnknownDateType
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
 @expectedDeprecation:
-%A  DateField is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\datetime\Plugin\migrate\field\DateField instead.
+

FAILURES!
Tests: 18528, Assertions: 29808, Failures: 2, Skipped: 2227, Incomplete: 1.

The tests pass when specifying the configuration file, that is, the following resulted in passing tests.

vendor/bin/phpunit -c core/phpunit.xml.dist core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php
vendor/bin/phpunit -c core/phpunit.xml.dist  core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldTest.php 

Two questions. One, what is the difference between running the test individually and running a whole testsuit? Two, why didn't testbot report an error?

neclimdul’s picture

Sure, good questions. Because of the legacy of Drupal 5 and 6 stupidnessstate complexity, testbot/run-tests.sh runs every test in its own process. For unit tests, phpunit runs in a single process because it is orders of magnitude faster and by definition those tests are supposed to be non deterministic/stateful (We change this behavior for kernel and web tests). Running tests individually obviously runs only that test and so in its own process.

Ideally we shouldn't test auto-loading because load order isn't explicit and is a sort of state we can't control. In reality our deprecation procedure needs tests and tests exactly that. When testing code inclusion(autoloading) like this, the tests must run in their own process. How to do that is documented here:
https://phpunit.de/manual/6.5/en/appendixes.annotations.html#appendixes....

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.

neclimdul’s picture

Version: 8.7.x-dev » 8.6.x-dev
heddn’s picture

Assigned: Unassigned » heddn

assigning to myself

heddn’s picture

Assigned: heddn » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.02 KB
neclimdul’s picture

Status: Needs review » Needs work

@runInSeparateProcess on works on the method. :(

heddn’s picture

Status: Needs work » Needs review
StatusFileSize
new1.49 KB

No interdiff.

neclimdul’s picture

Status: Needs review » Reviewed & tested by the community

Rockin! Thanks

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

@heddn, @neclimdul in an ideal world the PHPUnit fix would have in a followup. Re-opening issues for this is not great bbecause it just adds noise and work for people to figure out what's going on.

Committed and pushed e41655d1a3 to 8.7.x and 361b3188b7 to 8.6.x. Thanks!

alexpott’s picture

  • alexpott committed e41655d on 8.7.x
    Issue #2631698 followup by heddn, neclimdul: Fix sub-optimal DX in...

  • alexpott committed 361b318 on 8.6.x
    Issue #2631698 followup by heddn, neclimdul: Fix sub-optimal DX in...
berdir’s picture

> I was also iffy on removing things from the interface here, but given migrate_drupal isn't stable yet, I think I agree with @alexpott's #60 "However of course things are still implemented by the base classes that everyone would extend so that's good." Just noting this here so it's clear what the decision was if it comes back to bite us.

The stable/not stable with migrate and migrate_drupal is a pretty thin line, I actually didn't know that only migrate.module is stable :)

I don't think the argument makes quite sense about the base class and things being good. This broke paragraphs, and to be able to be compatible with 8.5 and 8.6 requires us to not rename but duplicate the methods and have both around (at least that's what we will try now, no patch uploaded yet).

Because if you don't implement both, then your logic will not be called in either 8.5 or 8.6. And we would probably not have even noticed if we wouldn't have test for our migrations.

See #2985549: Fix incorrect view display settings in LibraryItem (has a bunch of other test fixes too, but those at least are test-only).

Not quite sure that fixing "sub-optimal DX" (per issue title) is worth this API change?

heddn’s picture

Due to the poorly previous names of functions, the adoption of field plugins has been very slow and very confusing. And vastly less adoption for that very reason. Field plugins have unfortunately seen a lot of iteration and lots of BC duck-tape holding it together. I'm sorry that paragraphs got effected.

berdir’s picture

Yeah, I get that, but this is punishing those that *did* implement them now :)

I think the BC layer goes into the wrong direction here, I don't think anything cares about code *calling* those methods, why would anything except migrate do that? What it should care about is existing implementations that override the old methods that are no longer called, either by having an actual BC layer for that (but that's really hard without causing loops or something) or we could just be honest about this being a hard API break and do something like if method_exists($this, 'oldMethod') throw new \Exception('Rename X to Y!').

Then instead of silently no longer being called, invoking the non-updated plugins would actually fail hard with clear instructions on how to update it.

alexpott’s picture

Is there anyway to fix offer BC this was supposed to go in with a full BC layer. migrate_drupal has been beta stability which means we should only break API when we have to. This clearly is not a case of that so we invested time and effort in a BC layer. If that is not working then that is a problem.

phenaproxima’s picture

StatusFileSize
new7.04 KB

Well, this hack totally sucks, and I hate it, but maybe it'll do the trick. I offer it for your consideration.

phenaproxima’s picture

StatusFileSize
new5.51 KB

Another idea, which also totally sucks, but might work a little better. This is built on the assumption that no field plugin will implement both a deprecated method and its interface counterpart (i.e., nothing will explicitly implement both processFieldValues() and defineValueProcessPipeline()). Not sure how safe of an assumption that is, but it might do for now.

catch’s picture

Status: Fixed » Needs work

We should probably either roll this back or open up a follow-up, but since the discussion is currently happening here, re-opening.

phenaproxima’s picture

Status: Needs work » Needs review
StatusFileSize
new5.5 KB

Maybe this will work?

phenaproxima’s picture

So, @webchick (being the very helpful lioness that she is), gave me this: http://grep.xnddx.ru/

It's a site that lets one search all of Drupal contrib's code. Wow!

With that, I discovered that only a handful of modules are using the FieldPluginBase class: http://grep.xnddx.ru/search?text=Drupal%5Cmigrate_drupal%5CPlugin%5Cmigr...

It might be easiest, then, to just file patches against contrib to stop the bleeding. I will get on that shortly; it won't take long, and we should be able to maintain compatibility with both the 8.6+ and pre-8.6 APIs.

The question is...are we worried about custom migrations at all?

IMHO, one compromise that would not involve crazy reflection-based call chains is to simply implement a constructor in FieldPluginBase which detects if the concrete class is implementing the old methods, and throw deprecation notices if so. That would at least make the problem, and its change record, more visible.

Thoughts?

Status: Needs review » Needs work

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

heddn’s picture

IMHO, one compromise that would not involve crazy reflection-based call chains is to simply implement a constructor in FieldPluginBase which detects if the concrete class is implementing the old methods, and throw deprecation notices if so. That would at least make the problem, and its change record, more visible.

I really like this option. The number of custom folks who have written their own field plugins is very likely low. I'm not aware of any who's done that. Perhaps Berdir or others can correct me, but only contrib (and even there, that was few) were able to reverse engineer the esoteric field plugins.

berdir’s picture

I'm fine with closing this again.

Deprecation messages are really tricky to get right here as this shows. Lets make sure we open issues in the known contrib modules to update this and move on.

The problem with the suggestion of looking for old methods is actually problematic because it's fine to implement both, which is what we are doing in the paragraphs patch that I'm committing now. So we would need to specifically look for plugins that implement *only* the old method of each pair.

heddn’s picture

Status: Needs work » Fixed

Per #138, marking fixed again.

Status: Fixed » Closed (fixed)

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

wim leers’s picture

Published https://www.drupal.org/node/2944598 since this was committed in #125.