Skip to content

oro:entity-config:update / cache:clear should detect and warn about orphaned entity config entries instead of throwing fatal error #1137

@Genaker

Description

@Genaker

When switching git branches where one branch registered Doctrine entities via Oro entity config (migrations with oro_options) that do not exist in the other branch, cache:clear and any console command that boots the container throws a fatal unrecoverable error:


# php bin/console cache:clear --env=dev

 // Clearing the cache for the dev environment with debug true                                                          


In AbstractManagerRegistry.php line 175:
                                                                                    
  Class "...\Entity\ShipmentLineItem" does not exist  
                                                                                    

cache:clear [--no-warmup] [--no-optional-warmers]

There is no hint about where the stale registration comes from or how to fix it. The application becomes completely unable to boot, including commands like cache:clear itself.

#Steps to reproduce

On branch A: create a bundle with a Doctrine entity and a migration that registers it via oro_options / entity extend. Run oro:migration:load --force.
Switch to branch B where that entity class does not exist (git checkout branch-b).
Run php bin/console cache:clear --env=dev.

#Expected behaviour

One of the following:

oro:entity-config:update should detect classes registered in oro_entity_config that no longer exist on the filesystem and either remove them automatically or report them with a clear actionable message.
cache:clear should catch the ClassNotFoundException from Doctrine, identify the stale oro_entity_config row, and output a recovery hint such as:
Stale entity config found for class "X". Run: DELETE FROM oro_entity_config WHERE class_name = 'X';
Actual behaviour

Fatal error with no recovery path. The only fix is a manual raw SQL delete:

#Environment:
OroCommerce EE (latest)
PHP 8.x / Symfony 6.x
PostgreSQL

#Suggested fix:

Add a preflight check in oro:entity-config:update (or a dedicated oro:entity-config:validate command) that:

This would make branch switching safe without requiring manual DB surgery and hours of debug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions