Resolve legacy cache backend class names to their Symfony adapters (#41213) - #41236
Open
lbajsarowicz wants to merge 1 commit into
Open
Resolve legacy cache backend class names to their Symfony adapters (#41213)#41236lbajsarowicz wants to merge 1 commit into
lbajsarowicz wants to merge 1 commit into
Conversation
|
Hi @lbajsarowicz. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
Contributor
Author
|
@magento run all tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
2.4.9 routes cache creation through Symfony Cache.
Magento\Framework\App\Cache\Frontend\Factory::createSymfonyCache()passes the raw configuredcache/frontend/*/backendstring toSymfonyAdapterProvider::createAdapter(), and that provider resolves the value against$adapterTypeMap, which contained short aliases only (redis,valkey,memcached,libmemcached,file,database,apc,apcu,two_levels,twolevel). BothcreateAdapter()andcreateTagAdapter()end with$resolvedType = $this->adapterTypeMap[$backendTypeLower] ?? 'filesystem';, so a backend configured with a class name —Magento\Framework\Cache\Backend\Redis,...\Valkey,...\Database,...\Memcached, or the legacyCm_Cache_Backend_Redis— never matched and resolved to aFilesystemAdapter.Class names remain a supported configuration surface:
Factory::_getBackendOptions()accepts anyclass_exists()backend in itsdefault:case,Factory::isSymfonyL2Cache()already normalises a lowercased FQCN alongside its short aliases, and the class-name form is what the Redis page cache documentation shows. The result on an upgraded store is a cache that reports healthy fromcache:statusand the admin while every entry goes tovar/cacheand Redis stays empty.This change adds the lowercased class names to the existing map, next to the aliases they correspond to. Both call sites read the same map, so no new resolution logic is introduced.
Not included, deliberately: turning the
?? 'filesystem'default into an exception, and logging when the fallback is taken. Both are worth doing, but they are a behaviour decision rather than a bug fix — throwing would break installations running a custom backend class, and constructing a logger at cache bootstrap is circular with the cache itself. Happy to follow up in a separate PR if maintainers want the fallback to fail loudly or warn.Eaccelerator,MongoDb,RemoteSynchronizedCache,SymfonyL2CacheandAbstractBackendare intentionally left unmapped: they have no equivalent adapter in this map, andSymfonyL2Cacheis already handled byFactory::isSymfonyL2Cache().Note for whoever sequences this: #41159 also touches
SymfonyAdapterProvider.php(it addsresolveAdapterType()/isFilesystemBackend()helpers around the same fallback for the unrelatedcache_dirfix in #41157). The two changes are compatible but will conflict textually.Fixed Issues
Fixes #41213
Manual testing scenarios
app/etc/env.phpwith the class-name form:bin/magento cache:flush, browse a storefront page.redis-cli -n 1 dbsizestays0andvar/cachegrows. After: cache entries appear in Redis db 1 andvar/cachestays empty, matching the behaviour of'backend' => 'redis'with identicalbackend_options.Questions or comments
Gates run locally against
upstream/2.4-develop: unit (11 tests, 15 assertions — the newSymfonyAdapterProviderTest), PHPCS (0 errors, 0 warnings on both files), PHPStan (no errors), static/LiveCodeTest (green; 2 skips reproduce on a clean checkout). The unit tests avoid live services — Redis via an unconnected\Redisinstance, Memcached via theextension_loaded()failure Symfony raises before touching a socket, Database via a mockedResourceConnection— and two of them pin the unchanged filesystem default for an unmapped backend type.Contribution checklist (*)