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
If we save a link field just with the uri then the default options are set to NULL
instead of []
.
In core shortcuts are saved this way see standard_install()
.
It's major because it causes a bug in a major task #2502151: Convert shortcut block to view.
Proposed resolution
If default options value is not set in LinkItem::setValue()
then set it to []
.
Remaining tasks
Finalize the fix.
Review it.
Commit it.
User interface changes
None.
API changes
None
Comment | File | Size | Author |
---|---|---|---|
#19 | link_field_default-2502913-19.patch | 3 KB | jibran |
Comments
Comment #3
jibranNice found one more issue.
Comment #4
larowlanComment #5
larowlanManually tested too
Screenshot https://www.dropbox.com/s/2y5y35qeihx32kv/Screenshot%202015-06-10%2007.4...
Comment #6
alexpottWhy is this change necessary - isn't uri the main property?
Comment #7
jibranHow about now?
Comment #8
larowlanback again
Comment #11
jibranComment #12
alexpottI'm not sure that the
!is_string($values)
is actually necessary. If it is a string$values['options'] will be set.
Comment #13
tstoeckler@alexpott: So you are proposing to rely on PHP's behavior that
$foo = 'abc'; isset($foo['bar']);
returns TRUE? I have to strongly disagree, I think it makes the code wildly less readable. When you readisset($foo['bar'])
no one would expect$foo
to be a string. I'm fine with changing the!isset()
tois_array()
if people prefer that, but...Marking "needs review" to get some more opinions on this.
Comment #14
larowlanAgree with @tstoeckler
Comment #15
jibranThanks for the suggestion @alexpott and @tstoeckler. Thank you @larowlan for helping me understand the issue.
Comment #17
jibranComment #18
alexpottI think we should use $this->mainPropertyName() instead of hardcoding
'uri'
here.Why add title? It's optional?
No longer necessary to check if $values['options'] is set - it will always be.
Comment #19
jibranThanks for the review @alexpott. Fixed #18 added two more test cases. Updated docs.
Comment #20
Mac_Weber CreditAttribution: Mac_Weber as a volunteer commentedlooks good
Comment #21
alexpottCommitted e5d87b1 and pushed to 8.0.x. Thanks!
Removed unnecessary empty line on commit.
Comment #23
jibranThanks @alexpott for the commit. Thanks @Mac_Weber for RTBC.