Xml parser doesn't create array of values if value doesn't render to string

Created on 22 August 2019, almost 5 years ago
Updated 7 July 2023, 12 months ago

I found a small bug that is pretty obvious. In migrate_plus\src\Plugin\migrate_plus\data_parser\Xml.php if the value can't be cast to a string it sets the field instead of adding to the field array. I think the code speaks for itself:

# @see \Drupal\Plugin\migrate_plus\data_parser\Xml line 249
          // If the SimpleXMLElement doesn't render to a string of any sort,
          // and has children then return the whole object for the process
          // plugin or other row manipulation.
          if ($value->children() && !trim((string) $value)) {
            $this->currentItem[$field_name] = $value;
          }
          else {
            $this->currentItem[$field_name][] = (string) $value;
          }

So instead of this
$this->currentItem[$field_name] = $value;
it should be
$this->currentItem[$field_name][] = $value;

I'm gonna attach a patch.

πŸ› Bug report
Status

Needs work

Version

6.0

Component

Plugins

Created by

πŸ‡³πŸ‡±Netherlands dagomar

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024