This issue has been created
There are 3 updates.
 
 
XWiki Platform / cid:jira-generated-image-avatar-2ec38b71-e7ce-4ffb-ab17-8e39fbbb7649 XWIKI-24268 Open

Hibernate attachment versioning store loses the initial 1.1 version when an attachment is first updated

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-38a67979-3cdb-4e84-937c-8094719a6b0c Vincent Massol created this issue on 19/Apr/26 18:00
 
Summary: Hibernate attachment versioning store loses the initial 1.1 version when an attachment is first updated
Issue Type: cid:jira-generated-image-avatar-2ec38b71-e7ce-4ffb-ab17-8e39fbbb7649 Bug
Assignee: Unassigned
Created: 19/Apr/26 18:00
Priority: cid:jira-generated-image-static-major-51cc0de6-d9fd-4f2a-817b-0e3063ff517a Major
Reporter: Vincent Massol
Description:

When using the Hibernate (database) attachment versioning store, uploading an attachment for the first time creates version 1.1 but does NOT seed the JRCS archive. When the same attachment is re-uploaded (creating version 1.2), the archive is loaded empty, the version is incremented to 1.2, and a fresh JRCS Archive is created seeded only at 1.2 — making version 1.1 unrecoverable. All subsequent updates (1.2 → 1.3, etc.) work correctly.

Steps to reproduce:

  1. Configure xwiki.cfg with xwiki.store.attachment.hint=hibernate and xwiki.store.attachment.versioning.hint=hibernate
  2. Upload any attachment (e.g. test.txt) to a page — it appears as version 1.1
  3. Upload the same filename again with different content — version 1.2 is created
  4. View the attachment revision history — only version 1.2 is listed; version 1.1 is gone

Expected: Both 1.1 and 1.2 appear in the history.
Actual: Only 1.2 appears; 1.1 is silently lost.

Root cause: HibernateAttachmentVersioningStore.saveArchive() does not seed an empty archive before persisting it, unlike AttachmentArchiveSaveRunnable (filesystem store) which explicitly calls archive.addCurrentAttachment(context) when archive.getVersions().length == 0.

Fix: In saveArchive(), check archive.getRCSArchive() == null && archive.getAttachment() != null and call archive.addCurrentAttachment(context) before the DB write.

Affects: All XWiki versions using the Hibernate attachment store (confirmed on 15.10.x, 16.10.x, 17.10.x).

Forum report: https://forum.xwiki.org/t/attachments-v1-1-are-lost-when-being-updated/18417

 
 

3 updates

 
cid:jira-generated-image-avatar-38a67979-3cdb-4e84-937c-8094719a6b0c Changes by Vincent Massol on 19/Apr/26 18:01
 
Version: 17.10.7
Assignee: Vincent Massol
Component: Old Core