bug #3629597: Sequence ID widget shows the local entity ID, so saving an entity with a sequence reference fails

Closes #3629597

Problem

MapillarySequenceIdWidget::formElement() filled the text field with target_id, the local auto-increment ID of the mapillary_sequence entity. On save, massageFormValues() passed that value to MapillaryImageImporter::importSequence(), which looks it up as a Mapillary Sequence ID, finds nothing, asks the Graph API for /image_ids?sequence_id=1 and throws. An entity with a sequence value could not be saved again, even unchanged.

Changes

  • MapillarySequenceIdWidget::formElement() takes the default value from the referenced entity's sequence_id, as MapillaryLeafletSequenceWidget::getMapillaryId() already does. A reference whose target no longer exists shows an empty field, as in the Leaflet widget.
  • massageFormValues() is unchanged: with the Mapillary ID in the field, importSequence() finds the local sequence and makes no API request.
  • CHANGELOG entry under [Unreleased] / Fixed.

Tests

  • New MapillarySequenceIdWidgetFunctionalTest::testExistingValueSavesUnchanged(): the node edit form shows the Mapillary Sequence ID, and saving it unchanged keeps the reference. No access token is set, so any API request during the save would fail the test.
  • Before the fix the test fails with The field "field_mapillary_sequence[0][target_id]" value is "1", but "FUPDObC9uKcxo2AjprInVG" expected.
  • mapillary_field Unit (72) and Kernel (61) suites pass locally; phpcs (Drupal, DrupalPractice) is clean.

Notes

  • Creating a node with a sequence reference runs MapillarySequenceCascadeQueuer::enqueue() from hook_entity_insert(), which calls the Graph API inside the save and fails it without a token. The test therefore replaces the queuer in the test process only, as mapillary_leaflet_test does with NullSequenceCascadeQueuer. That behavior is a separate bug and will get its own issue.
  • No update needed: stored values do not change.

Merge request reports

Loading
Loading