Problem/Motivation
When migrating D7 sites (such as for example webchick.net), you get lots of errors like
Notice: Undefined index: text_processing in Drupal\text\Plugin\migrate\field\d7\TextField->getFieldType() (line 76 of core/modules/text/src/Plugin/migrate/field/d7/TextField.php).
Wim Leers provides the analysis for why this occurs for D7 sites that were upgraded from D6 in #25.
Steps to reproduce
Perform a migration with a D7 source site which has text fields without the text_processing setting.
Proposed resolution
Harden the code by specifcally handling the case where text_processing is not defined.
Add tests
Remove duplicate tests in the Drupal\Tests\text\Unit\Migrate namespace.
Remaining tasks
Patch
Review
Commit
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | interdiff_19-21.txt | 1.05 KB | shubham.prakash |
| #21 | 3165813-21.patch | 14.92 KB | shubham.prakash |
Comments
Comment #2
wim leersComment #3
huzookaComment #4
huzookaComment #5
huzookaFound the right place for testing the issue, no need for adding new test file 😊.
Comment #6
huzooka#5 has the test-only patch twice 😶, but not the complete one.
Comment #8
huzookaComment #9
wim leersWhy does this still need work? Looks ready to me :D
Comment #10
huzookaIt turned out that HEAD's
\Drupal\Tests\text\Unit\Migrate\d7\TextFieldTestis testing the Drupal 6 field plugin\Drupal\text\Plugin\migrate\field\d6\TextField, and not\Drupal\text\Plugin\migrate\field\d7\TextField.Comment #12
huzookaComment #13
huzookaI think that the unit test with the namespace
\Drupal\Tests\text\Unit\Plugin\migrate\field\d7\TextFieldTestis now complete.Since I don't see why we need two separate tests for the Drupal 7 TextField plugin, I removed the one with the namespace
\Drupal\Tests\text\Unit\Migrate\d7\TextFieldTest.Comment #15
huzookaIt seems that when
text_processingis completely missing from the settings, then it equals to havingtext_processing = 1.See #3168646: D7 sites upgraded from previous Drupal versions may not have a "text_processing" setting for their body fields.
Can anyone confirm this? I'm not familiar with Drupal 7 (anymore).
Comment #16
wim leersI know for a fact that that is how @webchick's site works at all at least 😎😅
Comment #18
quietone commentedChanging component to where the migrate maintainers will see this.
Comment #19
quietone commentedI'd like to understand why the case of text_processing not being set wasn't already handled. Is this a special case in D7? I don't know D7 very well so don't know.
I've only done a cursory look but the fix looks good. I do wonder if the deletion of core/modules/text/tests/src/Unit/Migrate/d7/TextFieldTest.php should be done in a separate issue.
In D7 why is text_processing not set?
Can we change these to empty instead of !empty? Just makes is a little easier to read.
Comment #20
wim leers… maybe … it is only happening for D7 upgraded from D6? Not sure, just theorizing. 🤔
Comment #21
shubham.prakash commentedDid the condition change as suggested in #19.
Comment #22
shubham.prakash commentedComment #23
shubham.prakash commentedComment #24
marvil07 commentedI see that 21 applied that change.
It seems like it is truly related, so unless some maintainer feel strongly about this, doing it here sounds OK.
If that is the case that change may also like to remove the
d7_filter_formatreferences overDrupal\text\Plugin\migrate\field\d6\TextFieldandDrupal\Tests\text\Unit\Migrate\d6\TextFieldTest.I was confused at first, on why
Drupal\Tests\text\Unit\Migrate\d7\TextFieldTestwas being removed.My first reaction was to address the problem by overriding the relevant methods to set the right plugin class.
The main reason seems to be that there is already another test dealing with the text migrate field plugin unit tests at
Drupal\Tests\text\Unit\Plugin\migrate\field\d7\TextFieldTest, which seems more relevant, and it is where the code has been added.It also brings up the question of unification of approach, and why
Drupal\Tests\text\Unit\Migrate\d6\TextFieldTestlives at a different namespace.A clear hint about it is that the two related classes are mostly the same, see textfieldunittest-migrate-vs-plugin-namespace.patch.txt, the output from
diff -up core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php.I would suggest to either open a follow-up about the duplication of code problem, or address it here, unifying d6 and d7 unit test likely with a test base class.
I am keeping the issue in NR to get an opinion from a migration subsystem maintainer.
Comment #25
wim leers#24:
Please do that in a follow-up.
We need to prioritize helping people migrating into D8|9 over code cleanliness, especially when it's only partial (but not complete) duplication of code.
#19:
I theorized in #20, where I wrote
I just checked that theory.
text_processing: https://git.drupalcode.org/search?utf8=%E2%9C%93&search=text_processing&...text_processing: https://git.drupalcode.org/search?utf8=%E2%9C%93&search=text_processing&...field_update_7001()— but has no special measures to ensure thattext_processinggets set. In fact, it doesn't really update the field configuration at all.Finally: the two cases where I know this to happen are Gábor Hojtsy's site and webchick's site. In both cases I know for a fact that their Drupal 7 sites are upgrades from previous versions of Drupal.
Updated title accordingly.
Comment #26
quietone commentedI reviewed the field plugins and the tests. It would help to have some comments in the field plugins explaining why text_processing may be empty.
Let's add a comment here explaining why text_processing is empty.
Add a comment here as well.
The tests do test what needs to be tested. Which is great but the changes for d6 are in one namespace and for d7 in another. Let's get them all into the correct namespace, which is
Drupal\Tests\text\Unit\Plugin\migrate\field.I have thought more about the deletion of the D7 test and still think it is out of scope and should be done in a followup that deletes both the D6 and D7 test in
\Drupal\Tests\text\Unit\Migrate. And with the changes to the tests to be done in the correct namespace that will be conceptually easier.The deletion of tests should always be questioned, so here is my reasoning. We know we can delete them because the D7 test in that namespace wrongly covers the D6 field plugin and the D6 test there is a functional duplicate of the D6 test in the correct namespace. Proof of that is given in the diff provided by marvil07 in #25. Thanks marvil07!
In regards to the duplicate code and adding a base class, there is no need to take on that work. The problem exists in many migrate tests and the focus on the work remains on functionality and bugs. The exception would be for tests in the migrate module itself.
Setting to NW.
Comment #27
wim leersLooking at this again, we'll also need to change this line to not fall back to
'0'but to'1'.Why?
See #15 + #16: both on webchick's site
text_processingis not set at all on her body field(s). But we still need to have text processing enabled in D8|9.This is what she has:
Comment #33
quietone commentedThe Migrate Drupal Module was approved for removal in #3371229: [Policy] Migrate Drupal and Migrate Drupal UI after Drupal 7 EOL.
This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
The deprecation work is in #3522602: [meta] Tasks to remove Migrate Drupal module and the removal work in #3522602: [meta] Tasks to remove Migrate Drupal module.
Migrate Drupal will not be moved to a contributed project. It will be removed from core after the Drupal 12.x branch is open.