Bug 16229

Summary: Koha::Cache should be on the safe side
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: abl, brendan, julian.maurice, tomascohen
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16166
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 16044    
Bug Blocks: 16166, 16221    
Attachments: Bug 16229: Deep copy on first L2 fetch
Bug 16229: Deep copy on setting in cache
Bug 16229: Add the unsafe flag to set_in_cache
Bug 16229: Add the unsafe flag to set_in_cache
Bug 16229: Deep copy on first L2 fetch
Bug 16229: Deep copy on setting in cache
Bug 16229: Add the unsafe flag to set_in_cache
Bug 16229: Deep copy on first L2 fetch
Bug 16229: Deep copy on setting in cache
Bug 16229: Add the unsafe flag to set_in_cache
Bug 16229: (QA) POD fixes

Description Jonathan Druart 2016-04-08 12:18:20 UTC
Theoretically our Koha::Cache is not as safe as possible, the set_in_cache and get_from_cache subroutines should always clone the structure to avoid uncontrollable behaviors.

There are, at least, 2 issues to cover:
- get_from_cache does not deep copy on first call
- set_in_cache does not deep copy

Note that bug 16221 plans to replace Clone::clone with Storable::dclone, it should be built on top of this patch.
Comment 1 Jonathan Druart 2016-04-08 12:23:31 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2016-04-08 12:23:36 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2016-04-08 12:23:40 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2016-04-08 12:35:27 UTC Comment hidden (obsolete)
Comment 5 Jacek Ablewicz 2016-04-13 14:48:53 UTC Comment hidden (obsolete)
Comment 6 Jacek Ablewicz 2016-04-13 14:49:07 UTC Comment hidden (obsolete)
Comment 7 Jacek Ablewicz 2016-04-13 14:49:14 UTC Comment hidden (obsolete)
Comment 8 Tomás Cohen Arazi 2016-04-14 13:51:57 UTC
Created attachment 50235 [details] [review]
Bug 16229: Deep copy on first L2 fetch

When a value exists in L2 cache but not in L1 cache, it should be deep
copied if needed (i.e. not a scalar). Otherwise the calling code is able
to modify the value in cache.
Note that is theoretical, it's possible that no code does that.

Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
Comment 9 Tomás Cohen Arazi 2016-04-14 13:52:02 UTC
Created attachment 50236 [details] [review]
Bug 16229: Deep copy on setting in cache

Koha::Cache->set_in_cache should deep copy (if needed) to avoid the
value which has been set in cache to be unintentionally modified later.

Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
Comment 10 Tomás Cohen Arazi 2016-04-14 13:52:08 UTC
Created attachment 50237 [details] [review]
Bug 16229: Add the unsafe flag to set_in_cache

Could be useful later.

Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
Comment 11 Tomás Cohen Arazi 2016-04-14 13:52:13 UTC
Created attachment 50238 [details] [review]
Bug 16229: (QA) POD fixes

Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
Comment 12 Brendan Gallagher 2016-04-20 17:41:58 UTC
Pushed to Master - Should be in the May 2016 Release.  Thanks!
Comment 13 Julian Maurice 2016-04-21 07:39:55 UTC
Not needed in stable versions, status changed to RESOLVED
Comment 14 Julian Maurice 2016-06-23 07:42:14 UTC
(In reply to Julian Maurice from comment #13)
> Not needed in stable versions, status changed to RESOLVED

Finally needed, because bug 16044 was pushed into 3.22.x
Patches pushed to 3.22.x, will be in 3.22.8