Incompatibility with "stof/doctrine-extensions-bundle" "translatable" extension #7362

Closed
opened 2026-01-22 15:50:39 +01:00 by admin · 1 comment
Owner

Originally created by @sebastien-confetti on GitHub (Apr 25, 2024).

BC Break Report

Q A
BC Break yes
Version doctrine/orm 3.1
BC Break no
Version doctrine/orm 2.18

Summary

A semantic error occurs when using the #[Translatable] attribute in an entity.

Previous behavior

All goes well.
No error is displayed.

Current behavior

The following error is displayed:

In AnnotationException.php line 36:

  [Semantical Error] The class "Doctrine\ORM\Mapping\MappedSuperclass" is not annotated with @Annotation.
  Are you sure this class can be used as annotation?
  If so, then you need to add @Annotation to the _class_ doc comment of "Doctrine\ORM\Mapping\MappedSuperclass".
  If it is indeed no annotation, then you need to add @IgnoreAnnotation("ORM\MappedSuperclass") to the _class_ doc comment of class Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation.

make:migration [--formatted] [--configuration [CONFIGURATION]]

How to reproduce

After installing stof/doctrine-extensions-bundle

composer require stof/doctrine-extensions-bundle

And made the following changes to the project:

  • doctrine.yaml
doctrine:
    dbal:
         ...
    orm:
        ...
    mappings:
       App:
           ...
       gedmo_translatable:
           type: attribute
           prefix: Gedmo\Translatable\Entity
           dir: "%kernel.project_dir%/vendor/gedmo/doctrine-extensions/src/Translatable/Entity"
           alias: GedmoTranslatable # (optional) it will default to the name set for the mapping
           is_bundle: false
    ...
  • TheEntity.php
<?php
namespace App\Entity;
...
use Gedmo\Mapping\Annotation\Translatable;
...
class TheEntity
{
    ...
    #[Translatable]
    private string $title = '';
    ...
}

And then makes a:

php bin/console make:migration

The following error is displayed:

In AnnotationException.php line 36:

  [Semantical Error] The class "Doctrine\ORM\Mapping\MappedSuperclass" is not annotated with @Annotation.
  Are you sure this class can be used as annotation?
  If so, then you need to add @Annotation to the _class_ doc comment of "Doctrine\ORM\Mapping\MappedSuperclass".
  If it is indeed no annotation, then you need to add @IgnoreAnnotation("ORM\MappedSuperclass") to the _class_ doc comment of class Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation.

make:migration [--formatted] [--configuration [CONFIGURATION]]

This is my first issue.
If I've made any mistakes in this one, I apologize.

Originally created by @sebastien-confetti on GitHub (Apr 25, 2024). ### BC Break Report <!-- Complétez les informations pertinentes ci-dessous afin de faciliter le triage de votre problème. --> | Q | A |------------ | ------ | BC Break | yes | Version *doctrine/orm* | 3.1 | BC Break | no | Version *doctrine/orm* | 2.18 #### Summary <!-- Fournissez un résumé décrivant le problème que vous rencontrez. --> A semantic error occurs when using the *#[Translatable]* attribute in an entity. #### Previous behavior <!-- Quel était le comportement antérieur (de travail) ? --> All goes well. No error is displayed. #### Current behavior <!-- Quel est le comportement actuel (non respecté) ? --> The following error is displayed: ``` In AnnotationException.php line 36: [Semantical Error] The class "Doctrine\ORM\Mapping\MappedSuperclass" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "Doctrine\ORM\Mapping\MappedSuperclass". If it is indeed no annotation, then you need to add @IgnoreAnnotation("ORM\MappedSuperclass") to the _class_ doc comment of class Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation. make:migration [--formatted] [--configuration [CONFIGURATION]] ``` #### How to reproduce <!-- Indiquez les étapes à suivre pour reproduire la rupture de la CB. Si possible, ajoutez également un extrait de code avec la configuration pertinente, les mappages d'entités, DQL, etc. L'ajout d'un test fonctionnel ou unitaire défaillant nous aiderait beaucoup - vous pouvez le soumettre dans une Pull Request séparément, en faisant référence à ce rapport de bug. --> After installing *stof/doctrine-extensions-bundle* ``` composer require stof/doctrine-extensions-bundle ``` And made the following changes to the project: - doctrine.yaml ``` doctrine: dbal: ... orm: ... mappings: App: ... gedmo_translatable: type: attribute prefix: Gedmo\Translatable\Entity dir: "%kernel.project_dir%/vendor/gedmo/doctrine-extensions/src/Translatable/Entity" alias: GedmoTranslatable # (optional) it will default to the name set for the mapping is_bundle: false ... ``` - TheEntity.php ``` <?php namespace App\Entity; ... use Gedmo\Mapping\Annotation\Translatable; ... class TheEntity { ... #[Translatable] private string $title = ''; ... } ``` And then makes a: ``` php bin/console make:migration ``` The following error is displayed: ``` In AnnotationException.php line 36: [Semantical Error] The class "Doctrine\ORM\Mapping\MappedSuperclass" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "Doctrine\ORM\Mapping\MappedSuperclass". If it is indeed no annotation, then you need to add @IgnoreAnnotation("ORM\MappedSuperclass") to the _class_ doc comment of class Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation. make:migration [--formatted] [--configuration [CONFIGURATION]] ``` > This is my first issue. > If I've made any mistakes in this one, I apologize.
admin closed this issue 2026-01-22 15:50:39 +01:00
Author
Owner

@mbabker commented on GitHub (Apr 25, 2024):

This is not a bug with the ORM.

You are trying to use the gedmo/doctrine-extensions package alongside ORM 3.x, and this package is not yet compatible with the new ORM version.

@mbabker commented on GitHub (Apr 25, 2024): This is not a bug with the ORM. You are trying to use the `gedmo/doctrine-extensions` package alongside ORM 3.x, and [this package is not yet compatible](https://github.com/doctrine-extensions/DoctrineExtensions/issues/2708) with the new ORM version.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7362