Problem/Motivation
Using the migrate_drupal
module, I was trying to write a module that has a UI that shows total number of rows processed over the total number of actual rows in the source DB. For example, if I have 42 articles in my Drupal 7 site and I process 13 of them, it would have a textual display that shows: 13/42 rows processed
.
As I was doing this, I discovered that the Variable
source plugin will return 0
for the total count if the configured variables don't exist, but initializeIterator()
will always return an iterator with 1
row. This leads to a weird case where my UI shows 1/0 rows processed
, which is nonsensical.
Proposed resolution
Check if the source has rows and return an iterator created from an empty array if the count of source rows is 0
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
Not necessary.