Field processor error with string values

Created on 12 May 2023, over 1 year ago

Problem/Motivation

When importing string data in a JSON field, I get the following error:

TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in count() (line 68 of migrate_source_jsonpath/src/Plugin/migrate/process/GetByJsonPath.php

Diving into the code, it looks like GetByJsonPath assumes that $result is an array. You can see this is true right on line 68:

    // If returned only one value.
    if (1 == count($result)) {
      $this->multiple = FALSE;
      $result = reset($result);
    }

Proposed resolution

Update the code to handle strings.

Remaining tasks

Create and test a patch.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States pianomansam

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024