Skip to content

NO-JIRA: Bugfix/reindex media on relate#552

Open
spirosdi wants to merge 2 commits into
developfrom
bugfix/reindex-media-on-relate
Open

NO-JIRA: Bugfix/reindex media on relate#552
spirosdi wants to merge 2 commits into
developfrom
bugfix/reindex-media-on-relate

Conversation

@spirosdi

Copy link
Copy Markdown
Contributor

What does this do?

  • Reindex the related Media when a Relation between Collection Object and a Media is created or deleted. So that the media's collectionspace_denorm:objectCsid field stays in sync with its relations.
  • Handles both directions (subject=Media/object=CollectionObject and subject=CollectionObject/object=Media)

Why are we doing this? (with JIRA link)
The public browser detail page image gallery finds media by querying collectionspace_denorm:objectCsid on Media docs. That field is only written when the Media doc itself is indexed, but relation create/delete events previously only reindexed the Collection Object. As a result newly related medias do not appear in the public browser until the media record is saved which triggers a reindex. Similarly, unrelated/deleted media keep showing until edited.

How should this be tested? Do these changes have associated tests?

  1. Create a media with an image, published to All
  2. From the media record, relate it to a collection object that is published to the public browser. Without editing the media, verify the image appears on the object's public browser detail page.
  3. Repeat the relation from the collection object's detail view and verify.
  4. Unrelate the media (from both the media side and the object side). Verify the image disappears from the public browser without editing the media.

Dependencies for merging? Releasing to production?
No dependencies

Has the application documentation been updated for these changes?
Changelog has been updated

Did someone actually run this code to verify it works?
@spirosdi ran it locally

Have any new security vulnerabilities been handled?
no new security vulns

@spirosdi
spirosdi requested a review from mikejritter July 15, 2026 17:16

@mikejritter mikejritter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason the first media I relate isn't showing up. Once I have one media the rest will index as expected. I'm going to spend a little bit of time to debug and see if it's something with my setup because the changes are straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants