Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I discovered that
\Laminas\Cache\Pattern\ObjectCache
, after being untangled and not inheriting fromCallbackCache
anymore, has changed the way the cache key computation is done and now is sensitive to all properties being present, and cannot deal with Closures present in them.This is described in issue #355.
Expected behaviour (identical with V3.x):
ObjectCache
allows to cache object trees that contain Closures, as they are not used to create a cache key.ObjectCache
is consistently creating the same cache key independent from any property values that are contained in the object tree.Observed behavior with V4.0 up to v4.1.0:
ObjectCache
throws an exception when encountering a Closure in a property.ObjectCache
creates differing cache keys if properties change inside the object tree.This proposal adds a test case indicator by simply forcing a useless Closure into the
\LaminasTest\Cache\Pattern\TestAsset\TestObjectCache
, which prevents serializing this object.Then a code path is added to
CallbackCache
that detects if an object is present in thePatternOptions
, which is taken as an indicator we are dealing withObjectCache
forwarding the call intoCallbackCache
, and apply the previously existing cache key logic that was present inObjectCache::generateCallbackKey()
from version 3.x. This will restore the previous behavior.This PR targets the 4.2.x branch, as there is currently only a minor lock file commit after the 4.1.x branch, and merging this fix may be considered serious enough to warrant a new minor release, as it reverts a major version change I consider to be accidental.