Closed (fixed)
Project:
Drupal core
Version:
8.9.x-dev
Component:
link.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 Jul 2020 at 06:37 UTC
Updated:
3 Aug 2020 at 09:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
shaktikComment #3
shaktikComment #4
shaktikComment #5
longwaveComment #6
lauriiiSince
$this->drupalCreateNode()creates a node as a side effect, we should probably keep the call in place even though we remove the variable.Comment #7
hardik_patel_12 commentedComment #8
hardik_patel_12 commentedKindly review a patch.
Comment #9
longwaveI am not quite sure the test is testing what it thinks it is testing, if it still works with the node creation step removed entirely, but still, the unused variable is gone.
Comment #10
alexpottSee #2804391: Resaving menu links that points to a non-node entity changes the type to node and breaks the link - this is test what it thinks it is testing. However the existence of the node has no impact on whether the test fails if you revert the logic in core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php to what is was before - therefore I vote for removing the node creation as it is irrelevant.
However that would mean fixing the comment too...
I'll ping @Berdir for an opinion.
Comment #11
berdirHm. Unsure. Agreed that the test does in fact fail without creating that node (and the argument we pass in is bogus, missing the title key), There are some slight differences though in the way it is broken. What I'm surprised about right now is that "foo (1)" still accepts and stores it as a entity:node/1 even if there is no node 1. An entity reference field would have a validation fail if you try to same. So it's kind of uncovered an additional bug, that we don't have the same valid reference validation on link-widget-with-an-entity-route as an actual entity reference field.
My gut reaction is to keep the node, maybe with an extra comment that explains that we ensure having a node with the same ID. And fix the wrong key for the node *and* also have a separate name for the two entity_test entities that we create, which both declare themself as "correct link target" now.
Comment #12
mradcliffeI think that this issue still could be a Novice issue because there's enough information to act on. The first step is to update the issue summary based on recent comments, and then make sure we're creating a patch that is "testing what we think we're testing".
Comment #13
ultrabob commentedI sought advice from @berdir about what is needed to move this ticket forward.
Given that I've added a comment to the previous patch to indicate why that node is being created.
Comment #14
ultrabob commentedI messed up the patch the first time, re-uploading.
Comment #15
nijolawrence commentedTested the patch. Patch applies without any issues. The changes have been made as per @berdir comments.
Comment #16
antojosenijolawrence missed to update the status as 'Reviewed & tested By the community', while working on this as part of the mentored contribution sprints post DrupalCon Global 2020.
Comment #17
alexpottAs per @Berdir let's add the title key... this should be
$this->drupalCreateNode(['title' => 'wrong link target']);Comment #18
avpadernoJust nitpicking: The comment should end with a period and it should not be longer than 80 characters; id should be ID; in to ensure that, that is not necessary; it's not clear what is that in the link doesn't match that.
(It still confusing, as it could refer to ID or test entity. It would be better to make that more explicit.)
Comment #19
ultrabob commentedThanks for the feedback @alexpott and @kiamlaluno. I'll submit a fix shortly.
Comment #20
ultrabob commentedHere's a patch addressing #18 and 19
Comment #21
nijolawrence commentedTested the patch. Patch applies without any issues.
Changes mentioned by @alexpott had been corrected.
Two more changes have to be made as per @kiamlaluno
1. The comment should not be longer than 80 characters.
2. id should be ID
Comment #22
ultrabob commentedThat's embarrassing. I assumed my IDE was set up to show me the 80 character width, but that setting was off. Here is a patch that actually addresses @kiamlaluno's comment.
Comment #23
nijolawrence commentedTested the patch. Patch applies without any issues. The changes have been made as per @alexpott and @kiamlaluno comments.
Comment #24
alexpottCommitted and pushed f884044d46 to 9.1.x and f83bd898fd to 9.0.x and 1b823bcd8c to 8.9.x. Thanks!
Backported to 8.9.x as this is a test only change.