Skip to content

[Caching] Invalidate on configured rule value change, reuse full-run cache for --only - #8400

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-cache-config-hash
Aug 29, 2026
Merged

[Caching] Invalidate on configured rule value change, reuse full-run cache for --only#8400
TomasVotruba merged 1 commit into
mainfrom
tv-cache-config-hash

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Two independent caching improvements.

1. Configured rule value changes now invalidate the cache

withConfiguredRule() stored its configuration on the RectorConfig instance only, never in the parameter bag that feeds the cache hash. So changing a rule's configuration - same rule class, different values - did not invalidate the cache and the old result was served.

 // rector.php
 return RectorConfig::configure()
     ->withConfiguredRule(SomeRector::class, [
-        'old value',
+        'new value',
     ]);

Before: cache kept, files re-analysed with the stale value.
After: cache dropped, files re-analysed with the new value.

The merged configuration is now pushed into a RULE_CONFIGURATIONS parameter, so it flows into the strict cache hash automatically. Upgrading invalidates the cache once for projects using configured rules.

2. --only <Rule> reuses the full-run cache

Each --only selection has its own cache namespace (#8075), so a file left clean by a prior full run was re-analysed under --only, even when nothing changed.

A scoped run now falls back to the full-run cache: a file the full run left clean (all rules at a fixed point) stays clean under a single rule too, and the file content is still compared, so a real edit is still picked up. The fallback is read only - a scoped run still writes only under its own key, so it never claims a full fixed point.

Before: --only SomeRector after a full run re-analyses every file.
After: it skips files the full run already left clean.

@TomasVotruba
TomasVotruba merged commit 597fa3e into main Aug 29, 2026
44 checks passed
@TomasVotruba
TomasVotruba deleted the tv-cache-config-hash branch August 29, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant