Skip to content

[dtq-dev-93] Reindex the previous version after the latest version is deleted - #1773

Open
milanmajchrak wants to merge 1 commit into
dtq-dev-93from
93/be-version-delete-reindex
Open

milanmajchrak wants to merge 1 commit into
dtq-dev-93from
93/be-version-delete-reindex

Conversation

@milanmajchrak

@milanmajchrak milanmajchrak commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

References

New fix, not a port. dtq-dev has the same code and the same bug; this PR fixes only dtq-dev-93.

Upstream DSpace main has the same deleteVersionedItem() code. It has no bug there, because upstream always unarchives the previous version. There is no upstream fix to copy.

Description

After the latest version of an item is deleted, the previous version now shows up in search right away. Before, it stayed hidden until someone edited it.

Instructions for Reviewers

List of changes in this PR:

  • DefaultItemVersionProvider.deleteVersionedItem(): clarin-dspace.cfg sets versioning.unarchive.previous.version = false, so the previous version stays archived when a new version is installed. Its Solr doc still gets latestVersion=false, because the install adds dc.relation.isreplacedby to it and reindexes it. On delete, the existing code re-archives and updates the previous item only when it is not archived. So it was never reindexed. A new else branch fires a MODIFY event for the previous item, so Discovery reindexes it as the latest version. It does not write to the DB or change lastModified.
  • DiscoveryVersioningIT.test_deleteLatestVersion_archivedPreviousVersionIsFoundAgain sets the property to false, creates and archives a second version, deletes it over REST, and checks that the first version is in the default search again.

How to test:

  • mvn verify -pl dspace-server-webapp,dspace -am -DskipIntegrationTests=false -Dtest=none -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false -Dit.test=DiscoveryVersioningIT. Without the change in DefaultItemVersionProvider the new test fails on latestVersion after the delete. VersionRestRepositoryIT, VersionHistoryRestRepositoryIT, CanDeleteVersionFeatureIT, ItemServiceIT, ClarinVersionedHandleIdentifierProviderIT and VersioningTest still pass.
  • By hand: archive an item, create a new version and deposit it. Search for the title: only the new version is found. Delete the new version. Search again: the old version is found right away.

Codex review (gpt-6.2-sol, high): no findings.

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & integration tests). Exceptions may be made if previously agreed upon.
  • My PR passes Checkstyle validation based on the Code Style Guide.
  • My PR includes Javadoc for all new (or modified) public methods and classes. It also includes Javadoc for large or complex private methods.
  • My PR passes all tests and includes new/updated Unit or Integration Tests based on the Code Testing Guide.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in any pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR modifies REST API endpoints, I've opened a separate REST Contract PR related to this change.
  • If my PR includes new configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

🤖 Generated with Claude Code

With versioning.unarchive.previous.version = false the previous version stays
archived, so deleting the latest version never reindexed it and it stayed out of search.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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.

1 participant