Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension / Rule change will not invalidate the cache #2969

Closed

Conversation

marcelthole
Copy link
Contributor

Hey 👋
we have the problem that the cache file is not invalidated if we change the code inside of a custom rule.

services:
    -
        class: CustomPHPStanRule\CustomRuleA
parameters:
	inferPrivatePropertyTypeFromConstructor: true
$ cat cache/phpstan/resultCache.php  | grep -A1 "projectExtensionFiles"
        'projectExtensionFiles' => array (
        ),

I expected the CustomRuleA in the projectExtensionFile. if this is there the normal cache workflow will also check the sha1 file sum and invalidates the cache.

With the current change the current service is always added as projectExtensionFile and every change on that file will invalidate the cache

@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

@ondrejmirtes
Copy link
Member

Please try to reproduce the problem first. Here you can see how we typically test result cache-related problems https://github.com/phpstan/phpstan-src/blob/1.11.x/.github/workflows/e2e-tests.yml

If a custom rule in a project will change, this must invalidate the cache to allow the new rule to find new issues
…ave dependencies to invalidate the search cache on changes inside of the service
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;

class CustomRule implements Rule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your custom rule should be part of your analysed paths. If you fix that I don't think you'll have this problem anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result cache not used because extension file /var/www/e2e/result-cache-8/src/CustomRule.php hash does not match.

👍 nice thanks a lot for the hint

@marcelthole marcelthole changed the title Add all passed services as projectExtensionFiles even if they don't h… Extension / Rule change will not invalidate the cache Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants