Problem/Motivation

While working on #2620364: Variable to config: theme settings [d7] I discovered that the extract plugin fails when the previous plugin returns multiple true. When that happens, extract tries to extract on a scalar and an exception is thrown.

The part of the process pipeline with the problem is the conversion of the D7 theme setting name to the D8 configuration name. Seemed simple enough but it doesn't work.

process:
  # build the configuration name from the variable name, i.e.
  # theme_bartik_settings becomes bartik.settings
  configuration_name:
    -
      plugin: explode
      source: name
      delimiter: _
    -
      plugin: extract
      index:
        - 1
    -
      plugin: concat
      source:
        -
        - constants/config_suffix

This pipeline works if both extract and get use 'handle_multiples = TRUE'. Note that #2500495: Upgrade path for Color 7.x uses this same pattern.

Data model changes

Proposed resolution

Add 'handles_multiples = TRUE' to the extract annotation.

Remaining tasks

User interface changes

N/A

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quietone created an issue. See original summary.

quietone’s picture

Title: Set handle_multiples true in Extract destination plugin » Set handle_multiples true in Extract process plugin

Correct title, s/destination/process.

quietone’s picture

quietone’s picture

Title: Set handle_multiples true in Extract process plugin » Pipeline using explode and extract fails

Hopefully, a more informative title.

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

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should 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.

rocketeerbkw’s picture

Status: Active » Needs review
FileSize
518 bytes

I understand why extract needs to handle multiples but I don't know what it has to do with the get process plugin.

benjy’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
chx’s picture

The patch is correct as far as I can see but yes needs tests.

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

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should 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.

mitrpaka’s picture

Testing if needs re-roll. It seems that target file has slightly changed. Patch updated.

curl https://www.drupal.org/files/issues/2675156-6-migrate_extract_process_handle_multiple.patch | patch -p1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   518  100   518    0     0    982      0 --:--:-- --:--:-- --:--:--   982
patching file core/modules/migrate/src/Plugin/migrate/process/Extract.php
Hunk #1 succeeded at 14 with fuzz 1.
maijs’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
3.56 KB
2.99 KB

A test that verifies multiple value handling has been added. The patch with a test only should fail.

Status: Needs review » Needs work

The last submitted patch, 11: 2675156-11-test-only.patch, failed testing.

maijs’s picture

Status: Needs work » Needs review

Test-only patch failed, but the other patch in #11 needs review.

iMiksu’s picture

Tests is looking good for me. Also together with the fix :)

iMiksu’s picture

Issue tags: +DCampBaltics
mikeryan’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 0aed30b to 8.3.x and 8dd44b1 to 8.2.x. Thanks!

  • alexpott committed 0aed30b on 8.3.x
    Issue #2675156 by maijs, rocketeerbkw, mitrpaka, quietone: Pipeline...

  • alexpott committed 8dd44b1 on 8.2.x
    Issue #2675156 by maijs, rocketeerbkw, mitrpaka, quietone: Pipeline...

Status: Fixed » Closed (fixed)

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

quietone’s picture

Always nice to see more testing.

However, the process pipeline in the test uses extract followed by extract, when the issue is about explode followed by an extract. And it seems the original problem is not fixed because #2827656: Once a process plugin returns multiple values, all following plugins are expected to handle multiple values was opened.

maijs’s picture

I agree that the test does not cover the whole explode-then-extract process, but the issue and the fix certainly does cover the immediate problem with the extract process plugin where it wasn't even able to catch multiple values at all. I propose to limit the scope of this issue only to process plugin while dealing with a more systematic problem with multi-value handling in #2827656.