The explode migrate process plugin annotation says that:

/**
 * @code
 * process:
 *   bar:
 *     plugin: explode
 *     source: foo
 *     limit: 1
 *     delimiter: /
 * @endcode
 *
 * If foo is "node/1/edit", then bar will be ['node', '1/edit']. The PHP
 * equivalent of this would be:
 *
 * @code
 *   $bar = explode('/', $foo, 1);
 * @endcode
 */

https://git.drupalcode.org/project/drupal/-/blob/10.1.x/core/modules/mig...

which is not true. To get an array of 2 elements the limit parameter should be 2

If limit is set and positive, the returned array will contain a maximum of limit elements with the last element containing the rest of string.

https://www.php.net/manual/en/function.explode.php

CommentFileSizeAuthor
#2 3327659-1.patch684 bytesklimp

Comments

klimp created an issue. See original summary.

klimp’s picture

StatusFileSize
new684 bytes

Status: Needs review » Needs work

The last submitted patch, 2: 3327659-1.patch, failed testing. View results

quietone’s picture

Version: 9.5.x-dev » 11.x-dev
Assigned: klimp » Unassigned
Category: Feature request » Task
Issue tags: -migrate, -explode, -annotation, -Documentation

This is a task. The patch still applies, so retesting.

quietone’s picture

Title: Fix annotation for the migrate explode process plugin. Wrong comment about the limit parameter » Fix limit value in Explode process plugin documentation.
quietone’s picture

Status: Needs work » Needs review

This should be NR.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems like a simple fix.

  • catch committed 9959c90a on 10.1.x
    Issue #3327659 by klimp: Fix limit value in Explode process plugin...

  • catch committed d4b4f2d3 on 11.x
    Issue #3327659 by klimp: Fix limit value in Explode process plugin...
catch’s picture

Version: 11.x-dev » 10.1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 10.1.x, thanks!

Status: Fixed » Closed (fixed)

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