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
Media::hasSourceFieldChanged()
checks whether a field value is equal to its original value. In FieldItemListInerface::equals()
we have an API for that to allow field types to control what it means to be "equal". Media::hasSourceFieldChanged()
does not utilize that, however.
Proposed resolution
Make Media::hasSourceFieldChanged()
use FieldItemListInerface::equals()
.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2894112-2.patch | 775 bytes | tstoeckler |
Comments
Comment #2
tstoecklerHere we go.
Test coverage is not feasible for this, in my opinion. It would require adding a test field type which does something "special" in
FieldItemInterface::equals()
so that it is distinguishable from a simple==
comparison. Then we would have to add a test media source plugin that utilizes such a field as a source field. And then in the actual test we would not only have to create a media item with this test source but perform a complicated series of method calls and checks on the media item becauseMedia::hasSourceFieldChanged()
is protected, so we cannot just call it directly.Comment #3
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedLooks good to me :)
Comment #5
Gábor HojtsyThe new code indeed looks cleaner too :)
Comment #6
Wim LeersYay!