Problem/Motivation

I tested creating a freeform text profile field in D6 and created 2 users that had content in the freeform text field, I tried to migrate the data to D8 and the data did not come across. The field name came across without any of the data, and it seems to have converted the profile field from free text, to an item list, and you can add new items as separate text fields. NOTE the problem does not occur if you in D6 separate list items by carriage return, but it does occur if you list your items in D6 using commas.

Proposed resolution

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Barnettech’s picture

Issue summary: View changes
jjpost’s picture

Assigned: Unassigned » jjpost
jjpost’s picture

Status: Active » Needs review
FileSize
3.63 KB

This patch makes sure the data splits on newlines and commas, fixing the issue. This patch includes updated test files.

ultimike’s picture

The patch looks good to me - thanks for adding the additional tests!

-mike

benjy’s picture

  1. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/ProfileFieldValues.php
    @@ -53,7 +53,8 @@ public function prepareRow(Row $row) {
    +        // Explode by newline and comma
    

    Missing full stop.

  2. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/ProfileFieldValues.php
    @@ -53,7 +53,8 @@ public function prepareRow(Row $row) {
    +        $row->setSourceProperty($profile_value['name'], preg_split("/(,)|((\r(?!\n))|((?<!\r)\n)|(\r\n))/", $profile_value['value']));
    

    This regex looks a bit much? How about:

    /[\r\n,]+/

    from: http://stackoverflow.com/a/3483314

ultimike’s picture

FileSize
2.72 KB
3.61 KB

Benjy,

That's a pretty little bit of RegEx that you found. Elegant solution.

I also beefed up the test a bit.

-mike

benjy’s picture

+++ b/core/modules/migrate_drupal/src/Tests/Dump/Drupal6User.php
@@ -450,7 +450,7 @@ public static function getData($table) {
+        array('fid' => 12, 'uid' => 2, 'value' => "AC/DC\n,,Eagles\r\nElton John,Lemonheads\r\n\r\nRolling Stones\rQueen"),

Do we need just a \n on it's own?

ultimike’s picture

FileSize
3.71 KB
2.57 KB

Sounds like a good idea. Updated patch attached.

Thanks,
-mike

jjpost’s picture

I used that long regex so it would catch single \n and \r\n. Some operating systems still produce \n, some produce \r and most \r\n (some info here: http://stackoverflow.com/questions/13092837/does-n-r-behave-differently-...).

The original plan was to use PHP_EOL, but I dont know how to put that in a regex.
Just using \r\n might break in some cases, the patch in #3 searches for \r\n and after that for \r and \n, so it will work in all cases.

benjy’s picture

Assigned: jjpost » Unassigned
Status: Needs review » Reviewed & tested by the community

As mentioned on the call I think it might be worth moving some of the stuff in prepareRow() into a process plugin at some point but that shouldn't hold this issue up since we want people to keep testing their migrations and this fixes the issue.

benjy’s picture

jjpost, the regex we have now searches for 1 or more of the characters in the regex so it handles the \n and \r cases as well as \r\n etc. This is shown by the tests still passing.

I don't think PHP_EOL would have worked since that is picked up from the current environment and that might be different from when the data was created.

jjpost’s picture

@benjy You are right, patch #8 works perfectly. Thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 5027a94 and pushed to 8.x. Thanks!

  • alexpott committed 5027a94 on 8.x
    Issue #2281627 by ultimike, jjpost | barnettech: Fixed Freeform text...

Status: Fixed » Closed (fixed)

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