Exception when using Xpath predicate

Created on 5 September 2018, over 6 years ago
Updated 13 March 2025, 25 days ago

I ran into an issue with a migration with XML data parser plugin when using an XPath attribute in its item_selector like item_selector: /Items/Item[@type="foo"].

The exception is : "Migration failed with source plugin exception: Index is defined as a source ID but has no value".

Looking at the code in Xml::fetchNextRow(), when an element matching the selector is found, $target_element gets it as SimpleXml and then tests the Xpath predicate. If the predicate is not empty but does not match the element, variable $target_element should be unset, otherwise if no "better" element is found in the XML document, the one in $target_element would still be used.

This case may happen when looking for a /Items/Item[@type="foo"] when we only have <items><item type="bar"></item></items>.

🐛 Bug report
Status

RTBC

Version

4.0

Component

Plugins

Created by

🇫🇷France greenjuls

Live updates comments and jobs are added and updated live.
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.

  • 🇪🇸Spain bmunslow

    I was hit by this as well, getting wrong total counts for some XML migrations whereby rows are filtered by a Xpath attribute. Patch is simple, straightforward and fixes the issue.

    Since it's such a simple fix, setting this to RTBC.

Production build 0.71.5 2024