Skip to content

SoftDeleteableEntity trait docblock @ORM\Column causes AnnotationException during cache warmup #3036

@BriceFab

Description

@BriceFab

Summary

Using Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity with a modern Symfony/API Platform stack that relies on PHP attributes causes cache warmup to fail because Doctrine Annotations tries to parse the trait's legacy @ORM\Column docblock.

Environment

  • PHP: 8.2.29
  • gedmo/doctrine-extensions: v3.22.0
  • stof/doctrine-extensions-bundle: v1.15.3
  • doctrine/annotations: 2.0.2
  • doctrine/orm: 3.6.2
  • doctrine/doctrine-bundle: 2.18.2
  • symfony/framework-bundle: v6.4.33
  • symfony/serializer: v6.4.33
  • api-platform/core: v3.4.17

Minimal setup

Entity:

use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\SoftDeleteable\SoftDeleteable;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;

#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: false)]
class Entity implements SoftDeleteable
{
    use SoftDeleteableEntity;
}

Reproduction

  1. Use API Platform routes/resources so metadata is loaded during cache warmup.
  2. Run:
php bin/console cache:clear -vvv

Actual result

Cache clear fails with:

[Semantical Error] The class "Doctrine\\ORM\\Mapping\\Column" is not annotated with @Annotation.
... add @IgnoreAnnotation("ORM\\Column") to property ...::$deletedAt

Stack includes:

  • Doctrine\Common\Annotations\AnnotationReader->getPropertyAnnotations()
  • Symfony\Component\Serializer\Mapping\Loader\AttributeLoader->getPropertyAnnotations()
  • API Platform metadata factories during route loading

Expected result

cache:clear should succeed when using SoftDeleteable with attributes-based mapping.

Observation

In the trait source, property $deletedAt contains both:

  • legacy docblock: @ORM\Column(type="datetime", nullable=true)
  • PHP attribute: #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]

The docblock annotation appears to be the trigger in this setup.

Question

Would you accept a patch that removes or neutralizes the legacy @ORM\Column docblock in SoftDeleteableEntity (while keeping attribute mapping), to avoid this failure with annotation parsing in modern stacks?

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