Skip to content

EVENT_PRE_REFERENCE does not support altering metadata in event subscriber #4627

@swirtSJW

Description

@swirtSJW

Current Behavior

If I create an event subscriber for LifeCycle::EVENT_PRE_REFERENCE and in that subscriber I alter metadata for the dataset, it does not persist. It gets overwritten because the reference uses the metadata from before the event is dispatched, rather than after any subscribers have run.

When referenceMetadata() fires it extracts the $metadata, then dispatches the event. Then my event subsciber alters the metadata inside $data. However then on line 361 it essentially saves the metadata that it set aside at the beginning, which is unchanged. So all my metadata maniplulation never got saved.

Expected Behavior

If I alter metadata as part of an event subscriber to LifeCycle::EVENT_PRE_REFERENCE, the alteration should persist and get saved with the referenced entity.

Steps To Reproduce

  1. Create an eventsubscriber to LifeCycle::EVENT_PRE_REFERENCE
  2. Alter the dataset node's metadata in the subscriber.
  3. Inspect the saved dataset and notice that the alteration did not get saved.
  4. Curse the PHP gods for their abject cruelty.

Relevant log output (optional)

Anything else?

This will be testable on PDC.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions