Change record status: 
Project: 
Introduced in branch: 
9.2.x
Introduced in version: 
9.2.0
Description: 

Configuration exports that contain newlines were previously formatted as one-line strings with escaped newline characters `\n`. This was difficult to read and made diff or merge tools more difficult to use.

Affected configuration exports will now use YAML multiline syntax (but only if they do not contain `\r`, due to YAML limitations). For example:

  key: An export\nthat contains\nline breaks

will now be exported as:

  key: |
    An export
    that contains
    line breaks

Site builders and module developers should expect changes in their configuration exports. We recommend re-exporting all configuration after updating to this version.

Impacts: 
Site builders, administrators, editors
Module developers

Comments

ghost of drupal past’s picture

Should you want to use this in an earlier version of Drupal on a site managed with composer (made with drupal-composer/drupal-project or drupal/recommended-project), you could add "symfony/yaml": "v4.4.21 as 3.4.5" to the project root level composer.json and run composer update symfony/yaml. Then patch core/lib/Drupal/Component/Serialization/YamlSymfony.php and you are done. The API surface of this library is small and the consumers are few so I think going from v3 to v4 should be fine. 1c9842d189 introducing Symfony v4 didn't need any YAML related changes.

danchadwick’s picture

See the issue comment #109 for a patch for drupal 8.9 that patches YamlSymfony.php as described.

pfrenssen’s picture

This can break certain configuration files that rely on the newline character being correctly represented. For example in my Migrate Plus configuration I have a processor that converts a multiline address from a migration source into an array.

Working migrate plus processor definition (before this change):

process:
  invoice_street_to_array:
    -
      plugin: concat
      source:
        - invoice_street
        - "\n"
    -
      plugin: explode
      delimiter: "\n"

Broken migrate plus processor definition (after this change):

process:
  invoice_street_to_array:
    -
      plugin: concat
      source:
        - invoice_street
        - |

    -
      plugin: explode
      delimiter: |

Ref. #3244757: Multiline YAML syntax is buggy with single newline character