Requiring a migration w/ a source plugin using a generator fatals

Created on 9 March 2016, almost 9 years ago
Updated 13 September 2023, over 1 year ago

Problem/Motivation

  1. Create a migration where initializeIterator yields. This is a great fit and works well.
  2. Now add this as a requirement to another migration.
  3. SourcePluginBase::count() gets called which in turn does $count = $this->getIterator()->count(); which fatals as Generator does not implement count().
  4. See $this->skipCount at the top of the method, add protected $skipCount = TRUE to the class.
  5. Observe the constructor unconditionally overriding this value.
  6. Tear your hair out.

Proposed resolution

Uh, I dunno, at least check whether the iterator is Countable before trying to count the bloody thing. And/or only pick up the skip_count from the configuration if it is set. This is one of those D7 vestiges which got ported and abandoned to bite us later.

Remaining tasks

doCount could use a little doxygen.

Write a test source plugin which uses yield and try to count it and assert it is -1. Check the configuration keys are picked up properly.

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

8.2 ⚰️

Component
MigrationΒ  β†’

Last updated about 13 hours ago

Created by

πŸ‡¨πŸ‡¦Canada chx

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.

Production build 0.71.5 2024