EntityAccessControlHandler::createAccess() should use whole context array when caching

Created on 5 November 2020, about 4 years ago
Updated 15 October 2024, about 1 month ago

Problem/Motivation

In 🐛 EntityAccessControlHandler::createAccess() and EntityAccessControlHandler::access() return false positive cache hits because it ignores context Needs work we prevented EntityAccessControlHandler::createAccess() from returning false postive cache hits because it was ignoring cache contexts. We did this by bypassing static caching when there was context.

Ideally though we could consider the context when looking results up in the cache.

Proposed resolution

Various suggestions were made in that issue for how to consider context in caching.

Serializing the context array and making this the cache id
@sam152 #15:

Is there a reason that $context can't be serialized and hashed as the default cid?

@ClaudiCristea #17:

Me and @hctom, we had a discussion on this. Indeed serializing the whole context would cover all cases. However, we both agreed that this could be performance cost. Context may contain arbitrary data, including entities. We probably would need to index context by keys, then serialize the whole array and, finally, convert to a hash. I'm sure this would be too expensive.

@Sam152 #28::

I'd be interested in some profiling that proves fixing this properly is slow. For the vast majority of handlers that don't pass a large number of complex objects, I'm guessing it wouldn't be a huge penalty?

Replacing the static cache with a memory cache service
@Claudiu.cristea #21:

A deep discussion about static caching should cover all aspects, static caching is problematic in many places. Probably, in many places we better move to a memory caching service that allows also modern cache invalidation and varying by using cache metadata.

Remaining tasks

Decide.
Implement.

User interface changes

None.

API changes

None.

Data model changes

None.

Feature request
Status

Active

Version

11.0 🔥

Component

entity system

Created by

🇬🇧United Kingdom jonathanshaw Stroud, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024