Open issues

Open issues

Known bugs and limitations of the current version of ufo-tech/doctrine-behaviors (2.0.0): symptom, cause and workaround. Fixed ones are on the Fixed issues page.

Behaviors work only for the default connection

Open

Affected versions: 1.0.0 — 2.0.0 (current).

Symptom. In an application with several Doctrine connections, entities of a manager working through another connection get no behavior columns and are not filled in (createdAt, slug, translations etc.).

Cause. All listeners in src/EventSubscriber/ are registered with #[AsDoctrineListener(..., connection: 'default')], so DoctrineBundle attaches them only to the event manager of the default connection.

Workaround. Register the listeners you need for your connection with the doctrine.event_listener tag and autoconfigure: false (so the attribute does not also attach a copy to default), e.g.:

services:
    app.timestampable_reporting:
        class: Ufo\DoctrineBehaviors\EventSubscriber\TimestampableEventSubscriber
        autoconfigure: false
        arguments:
            $timestampableDateFieldType: '%doctrine_behaviors_timestampable_date_field_type%'
        tags:
            - { name: doctrine.event_listener, event: loadClassMetadata, connection: reporting, priority: 500 }

BlameableEventSubscriber and SluggableEventSubscriber (via DefaultSluggableRepository) receive EntityManagerInterface in the constructor — pass your connection's manager to them as well (@doctrine.orm.reporting_entity_manager). The other listeners take the manager from the event arguments.


getRootNodes() does not find nodes made root via setChildNodeOf(null)

Open

Affected versions: 1.0.0 — 2.0.0 (current). Inherited from KnpLabs/DoctrineBehaviors.

Symptom. A node on which setChildNodeOf(null) was called is a root for isRootNode(), but TreeTrait::getRootNodes() does not return it.

Cause. A new node has materializedPath = '', while setChildNodeOf(null) writes '/'. getRootNodesQB() filters only materializedPath = ''.

Workaround. Do not call setChildNodeOf(null) for roots, or select roots with your own query: ->andWhere("t.materializedPath IN ('', '/')").


The translation locale column has length 5

Open

Affected versions: 1.0.0 — 2.0.0 (current). Inherited from KnpLabs/DoctrineBehaviors.

Symptom. A translation with a locale longer than 5 characters (sr_Latn, zh_Hant, de_CH_1996) is not saved on databases that check string length (MySQL in strict mode, PostgreSQL) — a "value too long" / "Data too long" error.

Cause. TranslatableEventSubscriber::mapTranslation() maps locale as a string with length: 5.

Workaround. The bundle does not map locale if the field is already mapped. Use TranslationMethodsTrait instead of TranslationTrait in the translation entity and declare the properties yourself:

use Ufo\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Ufo\DoctrineBehaviors\Contract\Entity\TranslationInterface;
use Ufo\DoctrineBehaviors\Model\Translatable\TranslationMethodsTrait;

#[ORM\Entity]
class CategoryTranslation implements TranslationInterface
{
    use TranslationMethodsTrait;

    #[ORM\Column(length: 16)]
    protected ?string $locale = null;

    protected ?TranslatableInterface $translatable = null;

    // ...
}

The package README and docs/ are outdated

Open

Affected versions: 2.0.0 (current). A documentation mismatch, does not affect behavior.

  • README.md states PHP >= 8.2, DBAL ^3.2 | ^4.2, ORM ^3.3, DoctrineBundle ^2.6 — in 2.0.0 it is PHP >= 8.4, DBAL ^4.2, ORM ^3.7, DoctrineBundle ^3.0.
  • The README behavior list lacks Sluggable and Loggable; Blameable is described as createdBy / updatedBy without deletedBy; Uuid — as "UUIDs as primary keys", although uuid is a separate column.
  • The "Usage" section links to the KnpLabs documentation; CHANGELOG.md ends at 1.0.0.
  • The examples in docs/*.md mostly use @ORM\Entity annotations, which Doctrine ORM 3 no longer has; translatable.md links to the non-existent github.com/Ufo/DoctrineBehaviors; tree.md does not mention that $root[0] needs ArrayAccess and that getTree() comes from TreeTrait in the repository.

The up-to-date description is on this site.