Problem/Motivation
SourcePluginBase has this line in its next() method:
$row = new Row($row_data, $this->migration->getSourcePlugin()->getIds(), $this->migration->getDestinationIds());
However, Row's constructor looks like this:
public function __construct(array $values = [], array $source_ids = [], $is_stub = FALSE)
$is_stub is supposed to be a boolean. SourcePluginBase is giving it an array.
The only reason this has ever worked is because Migration::getDestinationIds() returns the migration's $destinationIds property, which is an empty array -- that its default value, and nothing ever sets it differently; it's a vestigial property that should be removed from the Migration class. And the empty array evaluates to false (even PHPUnit's assertFalse() will not catch this).
So, entirely by accident, Row::isStub() does what it's supposed to do. If anything in Migrate did $row->isStub() === false
, it would break.
Additionally, the call uses a roundabout $this->migration->getSourcePlugin()->getIds() call instead of simply calling $this->getIds()
Proposed resolution
SourcePluginBase::next() should neither call another copy of itself, nor pass a third argument when creating the row. It defaults to FALSE anyway.
Remaining tasks
Write a fail patch, write a passing patch, RTBC, and swiftly commit.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
Fixed a bug where \Drupal\migrate\Row::isStub() could return an incorrect value, depending on how the object was instantiated.
Comment | File | Size | Author |
---|---|---|---|
#2 | 3017119-2.patch | 1.62 KB | phenaproxima |
#2 | 3017119-2-FAIL.patch | 888 bytes | phenaproxima |
Comments
Comment #2
phenaproximaHere we go.
Comment #3
phenaproximaForgot to change status.
Comment #4
phenaproximaComment #5
mikelutzDiscussed in slack with PhenaProxima. This is a clean, easy to understand, and obvious fix. I tweaked the issue title and summary a bit for accuracy. RTBC on appropriate red and green tests.
Comment #7
alexpottBring on strict types.
Committed and pushed 30cfcd03d0 to 8.7.x and 698f4703ff to 8.6.x. Thanks!