{"record":{"id":"2f15a45da476ed6a","repo":"doctrine/orm","slug":"invalid-argument-entity-class","errorCode":null,"errorMessage":"Invalid argument \"--entity-class\"","messagePattern":"Invalid argument \"--entity-class\"","errorType":"console","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Tools/Console/Command/ClearCache/EntityRegionCommand.php","lineNumber":72,"sourceCode":"not all cache providers are able to flush entries, because of a limitation of its execution nature.\nEOT);\n    }\n\n    protected function execute(InputInterface $input, OutputInterface $output): int\n    {\n        $ui = (new SymfonyStyle($input, $output))->getErrorStyle();\n\n        $em          = $this->getEntityManager($input);\n        $entityClass = $input->getArgument('entity-class');\n        $entityId    = $input->getArgument('entity-id');\n        $cache       = $em->getCache();\n\n        if (! $cache instanceof Cache) {\n            throw new InvalidArgumentException('No second-level cache is configured on the given EntityManager.');\n        }\n\n        if (! $entityClass && ! $input->getOption('all')) {\n            throw new InvalidArgumentException('Invalid argument \"--entity-class\"');\n        }\n\n        if ($input->getOption('flush')) {\n            $cache->getEntityCacheRegion($entityClass)\n                ->evictAll();\n\n            $ui->comment(sprintf('Flushing cache provider configured for entity named <info>\"%s\"</info>', $entityClass));\n\n            return 0;\n        }\n\n        if ($input->getOption('all')) {\n            $ui->comment('Clearing <info>all</info> second-level cache entity regions');\n\n            $cache->evictEntityRegions();\n\n            return 0;\n        }","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/doctrine/orm/blob/d9b9ff73016bf598ae07515f97289ce8074e97a5/src/Tools/Console/Command/ClearCache/EntityRegionCommand.php#L54-L90","documentation":"orm:clear-cache:region:entity evicts the second-level cache region of one entity class. Without an entity-class argument and without --all, there is no region to target, so the command throws InvalidArgumentException('Invalid argument \"--entity-class\"') before touching the cache.","triggerScenarios":"Running the command with no arguments and no --all; passing only --entity-id; passing an option where the positional class argument is expected.","commonSituations":"Deploy snippets written for the --all behaviour but missing the flag; automation assuming a default 'clear everything' semantic; command syntax mixed up with the region:query command.","solutions":["Pass the entity class: orm:clear-cache:region:entity 'App\\Entity\\User' (an optional second argument evicts one entry by id).","Pass --all to evict every entity region.","Check --help for the exact argument order before scripting it."],"exampleFix":"# before\n$ php bin/console doctrine:orm:clear-cache:region:entity\n# InvalidArgumentException: Invalid argument \"--entity-class\"\n\n# after\n$ php bin/console doctrine:orm:clear-cache:region:entity \"App\\Entity\\User\"\n# or all entity regions:\n$ php bin/console doctrine:orm:clear-cache:region:entity --all","handlingStrategy":"validation","validationCode":"// before invoking the command\n$entityClass = 'App\\Entity\\User';\nif ($entityClass === null && ! $all) {\n    throw new LogicException('Provide an entity class, or pass --all.');\n}","typeGuard":null,"tryCatchPattern":"Catch \\InvalidArgumentException around the command execution and re-raise as a usage error with the exact command syntax in the message.","preventionTips":["Script the exact usage line from --help (class argument, optional id, --all).","Prefer naming the class explicitly in deploy scripts; reserve --all for full flushes."],"tags":["doctrine-orm","console","second-level-cache","cli","cache"],"backgroundTag":"missing-required-argument","analyzedSha":"d9b9ff73016bf598ae07515f97289ce8074e97a5","analyzedAt":"2026-08-21T06:13:15.863Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}