Url source with JSON data parser throws exception with migmap_lookup process plugin

Created on 14 November 2022, about 2 years ago
Updated 3 October 2024, 4 months ago

Problem/Motivation

When using migmag_lookup to migrate from a url based source plugin using a json based data parser, the following errors were raised

[warning] Undefined variable $rows_to_stub MigMagMigrateStub.php:175
 [warning] foreach() argument must be of type array|object, null given MigMagMigrateStub.php:175  

These are caused because at the point

          // Stubbing needs prepareRow.
          if ($source_plugin->prepareRow($row)) {

an exception is thrown in the call to prepareRow() saying the row is frozen and cannot be changed. So no stubs are created.
I don't know why we need to call prepareRow() here as prepareRow() seems to be called by next() when iterating through the loop we are in

foreach ($source_plugin as $row)

Steps to reproduce

TBD - I need to work out the smallest use case with which I can replicate this.

Proposed resolution

Removing the inner prepareRow() stops the error and the migrate then works as expected.

Remaining tasks

  1. Work out why this seemingly unnecessary prepareRow() call exists.
  2. Remove it if safe to do so.
  3. Come up with a plan B if not.

API changes

No changes.

πŸ› Bug report
Status

Needs work

Version

1.8

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Eli-T Manchester

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.71.5 2024