Problem/Motivation
The text "Linked to content" appears twice when using the MediaThumbnailFormatter and linking to content, as shown in the screenshot below.

Steps to reproduce
- Create an entity reference field linking to a media entity
- In the Manage Display tab, change the formatter to Thumbnail (MediaThumbnailFormatter)
- In the display settings for that field, link to content.
- "Link to Content" shown twice in the summary.
Propused fix
Remove ''content' => $this->t('Linked to content'), from the $link_types array, since the parent settingsSummary() is already performing this check.
Remaining Tasks
Review and commit
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | interdiff-26-37.txt | 4.28 KB | danflanagan8 |
| #37 | 3078030-37.patch | 4.52 KB | danflanagan8 |
| #37 | 3078030-37-FAIL.patch | 3.33 KB | danflanagan8 |
Issue fork drupal-3078030
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3078030-duplicated-summary-item
changes, plain diff MR !1455
Comments
Comment #2
mottihoresh commentedproposed fixed
Comment #3
mottihoresh commentedComment #6
danflanagan8This issue is still in Drupal 9.4.x.
I'm changing this to "Normal" because in my experience, site builders are already confused when configuring Media reference fields to display. This bug only makes it more confusing.
The posted patch looks reasonable, but we'll need tests too.
Comment #7
danflanagan8Here's a fail test. There doesn't appear to be a ton of test coverage for stuff like this. I was hoping to just add a little to an existing test in media, but I didn't find any obvious candidates. In this new test class, I closely imitated
ResponsiveImageFieldUiTestfrom theresponsive_imagemodule.I'm also attaching a patch essentially adds the fix from #2. I've added a comment and made some stylistic changes, but it's essentially the same fix.
Comment #10
danflanagan8Arg, I missed changing the @group annotation when I copied over the test from responsive_image. That didn't cause any problems running the new test locally, but the bot doesn't like that one bit!
Here are those same patches but with the @group annotation on the new test fixed.
Comment #12
danflanagan8Well, the namespace is wrong. Sorry. Trying again.
Update: I got the namespace wrong because I was copying off of a strange test. I put in an issue here: #3248816: ResponsiveImageFieldUiTest.php should be moved to tests directory
Comment #14
danflanagan8Comment #15
danflanagan8Finally got it!
I've also updated the IS to include the original screenshot from @mottihoresh.
Comment #16
abhijith s commentedApplied patch #12 and the issue is fixed.
Before Patch:

After Patch:

RTBC +1
Comment #18
danflanagan8I just turned this into an MR because the media folks tend to prefer that. I applied the patch from #12 and broken it into two commits to start the MR.
Comment #19
andypostplease replace == with ===
Comment #20
danflanagan8Thanks, @andypost. I updated the MR.
I'm so confused about what branch things are supposed to target right now. Should I update the MR to target 9.3.x?
Comment #25
danflanagan8Comment #26
danflanagan8I'm picking this one back up with a different approach to testing. Instead of that bulky JS test, here's a Kernel test. This has the same fix as was in the MR.
Comment #28
danflanagan8That extra failure in each patch above is a known "random" fail: #3315753: Random fail in Drupal\Tests\media_library\FunctionalJavascript\WidgetUploadTest
The real failure to note in the fail patch looks perfect:
This failure is exactly what we see in the IS and it is fixed by 3078030-26.patch.
Setting back to NR since this only got bumped due to the random fails.
Comment #29
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200, following Review a patch or merge require as a guide.
Tried replicating this in 10.1 but did not see the issue.
Moving to NW if the steps to reproduce need to be updated.
Comment #30
danflanagan8This is still an issue in 10.1. The steps to reproduce in the IS look correct to me. The tests indicate the issue still exists as well. The key is selecting "Link image to content" in the field ui.
I'll throw this back to NR.
Comment #31
smustgrave commentedThanks for the quick reply.
I'll retest this.
Running the last patch against 10.1 one more time to see if that FunctionJavascript test passes.
Comment #32
danflanagan8Good idea, @smustgrave. I just re-queued the fail test in #26 as well, just to make sure it fails on the very latest.
Comment #34
danflanagan8Fail test in #26 still failing correctly on 10.1.
Comment #35
phenaproximaI think this looks like a really straightforward fix, and the test coverage is solid.
Nit: I don't know if data providers are normally supposed to have the () after the function name...? But hey, if it works, it's not a big deal.
These parameters should be type hinted as arrays, and documented in the method doc comment.
I feel like this is a bit lower-level than we should do.
I'd suggest we use the entity display system instead, which would allow us to respect the underlying abstractions:
This is a bit verbose, and we probably shouldn't call __toString() directly.
How about this instead?
Also, for clarity's sake, maybe $expected should be renamed to $expected_summary.
The keys 'content', 'media', and 'nothing' aren't the most descriptive. Could these be "link to content", "link to media", etc.?
Comment #36
danflanagan8Thank you for all the suggestions in #35, @phenaproxima. I followed the spirit of 35.3 but I had to create a new entity bundle with a media reference field in order to use the view display API. Since
media_thumbnailcan only be used on media reference fields, what I was doing didn't make sense anyway!Since there are so many changes in the test, I attaching a new test-only (aka FAIL) patch.
Comment #37
danflanagan8That was painful. These should be better.
Comment #39
smustgrave commentedCleaning up some of the files some
Reviewing #37
FAIL.patch shows the issue
Confirmed it manually also following the steps in the issue summary
Applying the fix did address the issue and the comments in the patch help explain why.
Comment #41
smustgrave commentedRandom Migrate failure again.
Comment #43
danflanagan8Those look like unrelated "random" fails in #42. Flipping back to RTBC.
Comment #45
danflanagan8Unrelated failure in Javascript.Drupal\FunctionalJavascriptTests\Tests\JSWebAssertTest
Back to RTBC
Comment #46
larowlanAdding issue credits
Comment #50
larowlanCommitted to 10.1.x and backported to 10.0.x and 9.5.x
Thanks folks
Comment #51
larowlan