entity_lookup plugin fails if $value is empty

Created on 23 November 2016, over 8 years ago
Updated 25 July 2024, about 1 year ago

I am using entity_lookup plugin at the end of a pipeline. Some of my entries do not have a value.

What I'm finding is that even if I use skip_on_empty or any other process plugins NONE of them even bother to run because the error is tripped during the construct phase, before the pipeline has even had a chance to run.

So essentially this plugin tries to set itself up before it even knows if it will be needed or not.

I found the problem is triggerd in the query method. Fortunately I know if the value is empty at the start of the query so I can simply not build the query object in that case. So I am starting the query method in entity_lookup with the following:

    if (empty($value)) {
      return NULL;
    }

...and now everything in the pipeline works as expected.

Earlier in my debugging process I found that if I did not run parent::__construct that would get me further along, but the above code seems to be a much better for now in my case.

πŸ› Bug report
Status

Needs review

Version

6.0

Component

Plugins

Created by

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States joegraduate Arizona, USA

    Created MR from patch #10 to trigger GitLab CI checks, etc.

  • Pipeline finished with Success
    about 1 year ago
    Total: 234s
    #234027
  • Status changed to Needs work 29 days ago
  • heddn Nicaragua

    Could we add test coverage?

  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    I can't say I remember working on this one, but it looks like I was pleased with the test in #8, which was included in the MR created by @joegraduate.

    Looking at the test only fail in Gitlab I see (from 11 months ago):

    1) Drupal\Tests\migrate_plus\Kernel\Plugin\migrate\process\EntityLookupTest::testLookupEntityWithoutBundles
    Failed asserting that false is null.
    /builds/issue/migrate_plus-2830058/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:122
    /builds/issue/migrate_plus-2830058/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:56
    /builds/issue/migrate_plus-2830058/tests/src/Kernel/Plugin/migrate/process/EntityLookupTest.php:110
    /builds/issue/migrate_plus-2830058/vendor/phpunit/phpunit/src/Framework/TestResult.php:729

    That doesn't look like too much of problem, eh? I wonder if the original failure (now lost to time) was more of an explosion than that. I wonder if something hasn't changed in this plugin since October 2022 that might make it handle null without blowing up.

    There's quite a bit of action on this plugin in the git history: https://git.drupalcode.org/project/migrate_plus/-/commits/6.0.x/src/Plug...

    I'm going to retrigger the pipeline in gitlab and see what it looks like.

  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    I can't seem to get the pipeline to run in Gitlab. Getting a console error and nothing happens. :shrug:

  • Pipeline finished with Failed
    25 days ago
    Total: 282s
    #545499
  • Pipeline finished with Success
    25 days ago
    #545501
Production build 0.71.5 2024