Closed (fixed)
Project:
Migrate Plus
Version:
6.0.x-dev
Component:
Plugins
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Jul 2017 at 20:20 UTC
Updated:
21 Jul 2025 at 21:39 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
segovia94 commentedThe problem is that line 237 in src/Plugin/migrate_plus/data_parser/Xml.php still has a valid target_element even though the predicate did not match earlier since as the final element it exited the loop instead of moving on to a new element.
2 Pages and 3 Posts are now correctly detected.

Comment #3
segovia94 commentedComment #4
heddnI hate to do this, but needs work because needs tests.
Comment #5
jcalais commented@heddn What tests are you specifically talking about? I just ran into this bug and spent a few hours solving it, only to end up here when I wanted to patch it and I need to up my test writing game, so maybe I could help out.
On a different note, which is preferred? unset($target_element) or $target_element = NULL? I would've gone with the first one out of habit mostly.
Comment #6
heddnHere's some guidance on test writing. https://www.drupal.org/docs/8/phpunit Look around for existing tests, but I doubt there are any for this code so this would be starting from scratch. I'd probably use unset() myself.
Comment #7
jocowood@jcalais: I added a duplicate bug report to this one. (see https://www.drupal.org/project/migrate_plus/issues/3004394). In this issue, the user somatick proved, you should prefer $target_element = NULL instead of unset($target_element), because it avoids the notice "$target_element is undefined".
Comment #10
codebymikey commentedComment #12
heddnThanks for writing tests in this space.