This issue has been created
There are 3 updates.
 
 
XWiki Platform / cid:jira-generated-image-avatar-5b5e630a-389f-44c0-90e1-825a36a6d31a XWIKI-22512 In Progress

Make sure to always return a clean document from the cache

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-01f74b15-f1ae-4038-ba01-c515eab971cc Thomas Mortagne created this issue on 17/Sep/24 03:55
 
Summary: Make sure to always return a clean document from the cache
Issue Type: cid:jira-generated-image-avatar-5b5e630a-389f-44c0-90e1-825a36a6d31a Improvement
Affects Versions: 16.7.1
Assignee: Unassigned
Components: Old Core
Created: 17/Sep/24 03:55
Priority: cid:jira-generated-image-static-major-6838e351-e9a0-4d03-ac3e-be4619091a39 Major
Reporter: Thomas Mortagne
Description:

It's easy to mess with the document in the cache for the other threads by modifying it without cloning it. Since that's a very common mistake, we should ideally find a way to fix that.

I can think of two possibility:
1. always return a cloned version of the document in cache
2. before returning the document from the cache, check if it was modified and reload it from the database if that's the case

The good thing with 1. is that it's safe, but it makes readonly uses case much slower, and it will clone the XWikiDocument twice in most (currently proper) cases. So I feel the best is 2., but we should also properly fix XWIKI-22510 and make extra sure that any modification leads to a dirty metadata flag set to true (for example, it's not the case right now for some plumbing modifications like the original document).

 
 

3 updates

 
cid:jira-generated-image-avatar-01f74b15-f1ae-4038-ba01-c515eab971cc Changes by Thomas Mortagne on 17/Sep/24 03:55
 
Description: It's easy to mess with the document in the cache for the other threads by modifying it without cloning it. Since that's a very common mistake, we should ideally find a way to fix that.

I can think of two possibility:
1. always return a cloned version of the document in cache
2. before returning the document from the cache, check if it was modified and reload it from the database if that's the case

The good thing with 1. is that it's safe, but it makes readonly uses case much slower, and it will clone the XWikiDocument twice in most (currently proper) cases. So I feel the best is 2., but we should also properly fix XWIKI-22510 and make extra sure that any modification leads to a dirty metadata flag set to true (for example, it's not the case right now for some plumbing modifications like the original document
, and it's needed to cover use cases like XWIKI-22511 ).
Assignee: Thomas Mortagne
Status: Open In Progress