doctrine/orm · error · InvalidArgumentException

Missing arguments "--owner-class" "--association"

Error message

Missing arguments "--owner-class" "--association"

What it means

orm:clear-cache:region:collection needs to know which collection region to evict: the owner entity class and the association name (an optional owner-id narrows it to one entry). Unless --all is passed, the command throws InvalidArgumentException('Missing arguments ...') as soon as either the owner-class or the association argument is absent.

Source

Thrown at src/Tools/Console/Command/ClearCache/CollectionRegionCommand.php:74

EOT);
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $ui = (new SymfonyStyle($input, $output))->getErrorStyle();

        $em         = $this->getEntityManager($input);
        $ownerClass = $input->getArgument('owner-class');
        $assoc      = $input->getArgument('association');
        $ownerId    = $input->getArgument('owner-id');
        $cache      = $em->getCache();

        if (! $cache instanceof Cache) {
            throw new InvalidArgumentException('No second-level cache is configured on the given EntityManager.');
        }

        if (( ! $ownerClass || ! $assoc) && ! $input->getOption('all')) {
            throw new InvalidArgumentException('Missing arguments "--owner-class" "--association"');
        }

        if ($input->getOption('flush')) {
            $cache->getCollectionCacheRegion($ownerClass, $assoc)
                ->evictAll();

            $ui->comment(
                sprintf(
                    'Flushing cache provider configured for <info>"%s#%s"</info>',
                    $ownerClass,
                    $assoc,
                ),
            );

            return 0;
        }

        if ($input->getOption('all')) {

View on GitHub (pinned to d9b9ff7301)

Solutions

  1. Pass both arguments: orm:clear-cache:region:collection 'App\Entity\User' 'addresses' (optionally the owner id as third argument).
  2. To evict all collection regions, pass --all.
  3. Run --help once and copy the exact usage line into your script.

Example fix

# before
$ php bin/console doctrine:orm:clear-cache:region:collection "App\Entity\User"
# InvalidArgumentException: Missing arguments "--owner-class" "--association"

# after
$ php bin/console doctrine:orm:clear-cache:region:collection "App\Entity\User" "addresses"
# or evict every collection region:
$ php bin/console doctrine:orm:clear-cache:region:collection --all
Defensive patterns

Strategy: validation

Validate before calling

// before invoking the command programmatically or from scripts
$ownerClass  = 'App\Entity\User';
$association = 'addresses';
if (($ownerClass === null || $association === null) && ! $all) {
    throw new LogicException('Provide owner-class AND association, or pass --all.');
}

Try / catch

Catch \InvalidArgumentException around the command execution in deploy tooling and surface it as a usage error, printing the command's --help text.

Prevention

When it happens

Trigger: Running the command with only the entity class, only the association, or nothing at all, without --all: php bin/console orm:clear-cache:region:collection 'App\Entity\User'.

Common situations: Adapted shell snippets that lost an argument; scripts assuming the command clears everything by default; automation copied between projects with different arguments.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of doctrine/orm@d9b9ff7301 (2026-08-21). Data as JSON: /api/errors/0786fa698638607b. Report an issue: GitHub.