Fixed issues
Bugs from previous versions and the version in which they were fixed. Open issues are on the Open issues page.
Typed property … must not be accessed before initialization in Blameable, Sluggable, SoftDeletable, Uuidable
Affected versions: 1.0.1 — 1.0.4.
Symptom. Error: Typed property App\Entity\X::$… must not be accessed before initialization:
- Sluggable, Uuidable — on
persist()of a new entity (generateSlug(),generateUuid()); - Blameable — on
persist()of a new entity when there is a user (getCreatedBy()), onremove()(getDeletedBy()), and for loaded entities withNULLin the column; - SoftDeletable —
isDeleted()/getDeletedAt()of a new entity.
Cause. In 1.0.1 the trait properties became typed without default values (protected string $slug;, protected UuidInterface|string|null $uuid; etc.), and the methods read them before initialization.
Fix. In 2.0.0 the properties got default values (null, '' for slug), Blameable a nullable type. On 1.0.x, for Sluggable, Uuidable and SoftDeletable you can initialize the properties in the entity constructor ($this->slug = '', $this->uuid = null, $this->deletedAt = null); for Blameable — use BlameableMethodsTrait and declare createdBy / updatedBy / deletedBy yourself with a nullable type.
The package did not declare the symfony/security-bundle dependency
Affected versions: 1.0.0 — 1.0.4.
Symptom. In an application without symfony/security-bundle the container does not build: the Ufo\DoctrineBehaviors\Provider\UserProvider service cannot be autowired.
Cause. UserProvider depends on Symfony\Bundle\SecurityBundle\Security, while composer.json required only symfony/security-core.
Fix. In 2.0.0 symfony/security-bundle was added to require. On 1.0.x — install it in the application.
Timestampable: error when saving a new entity
Affected versions: 1.0.1 — 1.0.2.
Symptom. persist() + flush() of a new entity with TimestampableTrait ends with Error: Typed property …::$createdAt must not be accessed before initialization.
Cause. protected DateTimeInterface $createdAt; has no default value, while updateTimestamps() checks $this->createdAt === null.
Fix. The properties are ?DateTimeInterface with a null default (PR #1).
Translatable: invalid merge cascade in ORM 3
Affected versions: 1.0.0 — 1.0.1.
Symptom. When loading metadata of entities with TranslatableInterface / TranslationInterface, Doctrine ORM 3 throws a MappingException about the invalid cascade option merge.
Cause. TranslatableEventSubscriber mapped the translations and translatable relations with cascade: ['persist', 'merge', …]; ORM 3 allows only persist, remove, refresh, detach.
Fix. The merge cascade was removed.