Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Note will cause trivial conflict with #2273971: migrate EntityComment should use the $row->stub() method
Beta phase evaluation
Prioritized changes | The main goal of this issue is an improvement to Migrate, so it is a prioritized change during the beta phase. |
---|---|
Disruption | Changes one rarely used public method, the constructor for the Row object, and a protected property only, so minimally disruptive. |
Comment | File | Size | Author |
---|---|---|---|
#20 | interdiff.txt | 2.42 KB | mikeryan |
#20 | rename_row_stub_to-2275377-20.patch | 7.24 KB | mikeryan |
#16 | rename_row_stub_to-2275377-16.patch | 5.55 KB | mikeryan |
#6 | interdiff-3-6.txt | 1.18 KB | martin107 |
#6 | renameStub-2275377-6.patch | 2.74 KB | martin107 |
Comments
Comment #1
martin107 CreditAttribution: martin107 commentedCurrent there are only 2 uses of '$VARIABLE->stub()' in core
$row->stub(TRUE/FALSE); is not used YET, but that functionality exists, as a setter, to update the protected variable $stub inside the instance of \Drupal\migrate\Row
Reviewers can comment on whether that future-proofing should be preserved with the setStub method provided by the patch?
Comment #2
chx CreditAttribution: chx commentedDon't split it; ContentEntityBase::isDefaultRevision() is not split either.
Comment #3
martin107 CreditAttribution: martin107 commentedComparing with ContentEntityBase::isDefaultRevision() - shows that Row::isStub() should also have an explicit cast to bool.
Comment #6
martin107 CreditAttribution: martin107 commented1) All tests now pass locally.
2) Also updated comment to reflect newly constrained return type.
Comment #7
martin107 CreditAttribution: martin107 commentedComment #8
chx CreditAttribution: chx commentedLike it, thanks.
Comment #9
YesCT CreditAttribution: YesCT commentedThis doesn't make sense to me. I think there should be separate getter and setter.
Now we are using isStub() to also get/set? Still a naming confusion.
wait.
... if this does not return values now, and always is true/false... then the docs need to be updated also.
Comment #10
YesCT CreditAttribution: YesCT commentedwhy should we passing TRUE knowing it is a stub, in order to find out *if* it's a stub.
Seems like the param should not be there.
I would also suggest renaming the property to isStub, since it is not setting/storing the stub value, but just if it is a stub or not.
Comment #11
chx CreditAttribution: chx commentedThis is how ContentEntityBase::isDefaultRevision() works which was the only simple set bool - retrieve bool I could find. I am not inventing anything here.
Comment #13
martin107 CreditAttribution: martin107 commented6: renameStub-2275377-6.patch queued for re-testing.
Extract from Drupal\aggregator\Tests\AggregatorConfigurationTest
Drupal\action\Tests\BulkFormTest passes locally for me...
Testbot is overworked and at a DrupalCon, so I am retesting thinking this test fail is just a bots drunk stumble...
I don't want to start a 'bikeshed' but on reflection
1) I don't think ContentEntityBase::isDefaultRevision() should be taken as an example of good design.
2) Splitting into a isStub and setStub will not break the principle of "causing least surprise"
Whereas I cannot conceive of explaining this code to a new developer without using the phrase
, and so can't justify what we have as a new patch...
3) Since having a setter was in my first patch ... I will leave it for other to change if they wish to ... for now I will just ask for a retest
Comment #14
chx CreditAttribution: chx commentedI unfollow this issue; I already had a really angry rant on IRC. There's a limit of how much bikesheeding I can take. Hint: the setter will never be called by anything outside of migrate and inside migrate it will be called once.
Comment #15
benjy CreditAttribution: benjy commentedThe patch in #6 makes less sense than what we have now. an "isStub" method that also supports setting doesn't fit that well.
Either we add the setter back and make isStub only return the value or I prefer we just leave this as "stub" to be honest, it's only used internally to migrate from what i'm aware.
Comment #16
mikeryanA Row is either a stub or not - it's not something that's ever going to change dynamically during a row's lifetime. So, why not set it in the constructor?
Comment #17
benjy CreditAttribution: benjy at CodeDrop commentedYes, I agree with that. RTBC!
Comment #18
xjmMigrationInterface::getDestinationPlugin()
has an undocumented (and apparently Boolean) parameter named$stub
. Should that be renamed too?I'd think seeing
$stub
that it was an actual stub row object. Maybe$create_stub
or such would be a better name? Edit: And if the parameter forgetDestinationPlugin()
is actually supposed to be like this rather than an "is", then we should rename that to the same thing instead.Moving it to the constructor makes sense to me too.
Thanks all!
Comment #19
xjmAdding a beta evaluation... stub. ;)
Comment #20
mikeryanThe other $stub/stub() instances we're dealing with directly represent the state of the Row object, this is used to validate that the destination plugin supports stubbing before creating the stub Row. We could call it... $stub_being_requested? That does make the line where it's used pretty clearly self-documenting...
Comment #21
benjy CreditAttribution: benjy at CodeDrop commentedSounds OK to me.
Comment #22
xjmThat works, thanks!
As a Migrate improvement, this issue is a prioritized change during the beta phase per https://www.drupal.org/core/beta-changes, and I agree that the minor BC break is merited by the improved code legibility. Committed and pushed to 8.0.x (with credit for reviewers).
Comment #24
xjmHm, it occurs to me that this should probably have a small change record for the method rename.
Comment #25
benjy CreditAttribution: benjy at CodeDrop commentedWe've never created change records before for Migrate, maybe because it's currently an un-supported/released API?
Happy to do it though if you think we should start?
Comment #26
xjm@benjy, interesting point. I was thinking that it would help contrib modules writing migrations to notify them about the BC break, but maybe we don't need it for the same reasons we only did major 8.x to 8.x change records before the beta. Since this is a small break I guess there's no need to bother.
When do you think it would make sense to start adding them? For major API changes now, and then for any BC break starting during RC?
Comment #27
xjmComment #28
benjy CreditAttribution: benjy at CodeDrop commentedYeah I think major API changes would warrant a CR at this point and RC seems like a good milestone to start CR's for everything else.