fix: conditional (BC) removal in RemoveAliasManagerCacheMethodCallsRector#405
Merged
bbrala merged 2 commits intoJul 7, 2026
Merged
Conversation
…unconditionally [#3600789] RemoveAliasManagerCacheMethodCallsRector removed calls to AliasManager::setCacheKey()/writeCache() unconditionally, which breaks backward compatibility on Drupal < 11.3. These methods only became no-ops in 11.3.0 (when the path alias preload cache was replaced by a Fiber-based bulk-lookup strategy); before 11.3.0 they performed real caching work. The rector now extends AbstractDrupalCoreRector. When BC support is enabled the call is wrapped in a DeprecationHelper::backwardsCompatibleCall() with a no-op current callable, so the caching still runs on Drupal < 11.3 and is skipped on 11.3+. When BC support is disabled the call is removed as before. Reported by Berdir.
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.
Problem
RemoveAliasManagerCacheMethodCallsRectorremoved calls toAliasManager::setCacheKey()/writeCache()unconditionally. As reported by Berdir on #3600789, that breaks backward compatibility on Drupal < 11.3.These methods only became no-ops at 11.3.0, when the path alias preload cache was replaced by a Fiber-based bulk-lookup strategy (CR 3496369, CR 3532412). Before 11.3.0 they performed real caching work, so deleting the call outright silently drops the alias preload caching for modules that still support < 11.3.
Fix
The rector now extends
AbstractDrupalCoreRector(version-gated on11.3.0):BC support enabled → the call is wrapped in a
DeprecationHelper::backwardsCompatibleCall()with a no-op current callable, so the caching still runs on Drupal < 11.3 and is skipped on 11.3+:BC support disabled (or minimum supported core ≥ 11.3) → the call is removed as before.
Verified against core source:
backwardsCompatibleCall()takes two requiredcallableparams and invokes one based on the version compare; afn() => nullcurrent callable is valid and its return is discarded in statement context. No deprecation notice fires because the deprecated method is only invoked on the < 11.3 branch. The sharedcreateBcCallOnExpr()helper can't produce this shape (it needs a replacementExpr; this is a whole-statement deletion), so the wrapper node is built in the rector, keeping theExpression-level match.Real-world validation (contrib search)
Every contrib module that actually calls these methods on an
AliasManagerhas already added a manual BC guard — confirming unconditional removal is wrong and the conditional approach is correct:if ($this->aliasManager instanceof AliasManager && version_compare(\Drupal::VERSION, '11.3', '<'))(Berdir's MR !196)if (method_exists($this->inner, 'setCacheKey'))SeoUrlManager(notAliasManager), so the type guard correctly skips itContrib
writeCache()hits are almost allModuleHandler::writeCache()and other unrelated methods, notAliasManager— correctly ignored by the type guard.Tests
fixture-bc/— proves the BC wrapper output (basic + concrete receiver).fixture/— proves plain removal when BC is disabled.fixture-below-version/— proves the rector does not fire when target Drupal < 11.3.Full suite green (699 tests), PHPStan clean, php-cs-fixer clean.
🤖 Generated with Claude Code