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.
Problem/Motivation
LinkItem::getUrl doesn't respect any options it may hold.
This prevents us from being able to write an enhanced widget for setting attributes etc.
See https://www.drupal.org/project/link_attributes for one such widget.
Proposed resolution
Do so
Remaining tasks
Review
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#19 | link-options-null-2760557.patch | 540 bytes | Berdir |
#7 | 2760557-link-options.2.patch | 1.33 KB | larowlan |
#3 | 2760557-link-options.pass_.patch | 1.42 KB | larowlan |
#3 | 2760557-link-options.fail_.patch | 842 bytes | larowlan |
Comments
Comment #2
larowlanComment #3
larowlanSimple bug
Comment #4
jibranWhy not just pass the options as 2nd param?
Comment #5
larowlanComment #7
larowlanjibran++
Comment #8
larowlanBlocks https://www.drupal.org/project/link_attributes
Comment #9
jibranNice and easy thanks @larowlan. For D8 it's forwardport policy.
Comment #10
dawehnerJust a shameless ad about some other issue :) #2656534: Provide a way to extract a menu plugin from a menu form
This looks perfect for me.
Comment #11
jibranI have another ad as well #2477155: Update LinkWidget to accommodate the attribute.
Comment #13
jibranEverything is green.
Comment #14
alexpottCommitted and pushed f94a4c2e13a6d77d757a1d396268c0764725c093 to 8.2.x and 8a7eab2 to 8.1.x. Thanks!
Comment #18
BerdirInteresting, this breaks an older D8 site that I have pretty badly. For some strange reason, I have N; (serialized NULL) in the options column for my shortcuts. passing NULL along results in a recoverable fatal error.
Looking a bit more, I can see that in at least 4 older D8 sites, some are empty arrays, some NULL. Expecting them all to choke on this.
Quick patch to prevent that, need one for composer, will open a new issue later.
Comment #19
BerdirComment #20
Berdir#2787183: LinkItem::getUrl() fails if options are NULL