Bug 16229 - Koha::Cache should be on the safe side
Summary: Koha::Cache should be on the safe side
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on: 16044
Blocks: 16166 16221
  Show dependency treegraph
 
Reported: 2016-04-08 12:18 UTC by Jonathan Druart
Modified: 2019-06-27 09:24 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 16229: Deep copy on first L2 fetch (1.98 KB, patch)
2016-04-08 12:23 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 16229: Deep copy on setting in cache (1.72 KB, patch)
2016-04-08 12:23 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 16229: Add the unsafe flag to set_in_cache (2.10 KB, patch)
2016-04-08 12:23 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 16229: Add the unsafe flag to set_in_cache (2.38 KB, patch)
2016-04-08 12:35 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 16229: Deep copy on first L2 fetch (2.04 KB, patch)
2016-04-13 14:48 UTC, Jacek Ablewicz
Details | Diff | Splinter Review
Bug 16229: Deep copy on setting in cache (1.79 KB, patch)
2016-04-13 14:49 UTC, Jacek Ablewicz
Details | Diff | Splinter Review
Bug 16229: Add the unsafe flag to set_in_cache (2.45 KB, patch)
2016-04-13 14:49 UTC, Jacek Ablewicz
Details | Diff | Splinter Review
Bug 16229: Deep copy on first L2 fetch (2.08 KB, patch)
2016-04-14 13:51 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 16229: Deep copy on setting in cache (1.83 KB, patch)
2016-04-14 13:52 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 16229: Add the unsafe flag to set_in_cache (2.49 KB, patch)
2016-04-14 13:52 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 16229: (QA) POD fixes (1.97 KB, patch)
2016-04-14 13:52 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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