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().

CommentFileSizeAuthor
#2 2894112-2.patch775 byteststoeckler
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler created an issue. See original summary.

tstoeckler’s picture

Status: Active » Needs review
FileSize
775 bytes

Here 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 because Media::hasSourceFieldChanged() is protected, so we cannot just call it directly.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me :)

  • Gábor Hojtsy committed 13c94df on 8.4.x
    Issue #2894112 by tstoeckler: Media::hasSourceFieldChanged() must use...
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

The new code indeed looks cleaner too :)

Wim Leers’s picture

Yay!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.