You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I save contentA with a contentB selected I see the relation in database.
After I save the contentB without or with a contentC selected, the relation between contentA and contentB is removed.
I see in the contentEditController, all the relation is removed before insert new:
//...
private function updateRelation(Content $content, $newRelations): void
{
$newRelations = (new Collection(Json::findArray($newRelations)))->filter();
$currentRelations = $this->relationRepository->findRelations($content, null, true, null, false);
// Remove old ones
foreach ($currentRelations as $currentRelation) {
$this->em->remove($currentRelation);
}
//...
I understand why relation is removed but I don't understand why reverse relation are removed too.
So I made a fix which change the bidirectionnal attribute: $currentRelations = $this->relationRepository->findRelations($content, null, false, null, false);
Do you think there will be side effect ?
The commit in my repo with the modification : novaway@35c7a6e
The text was updated successfully, but these errors were encountered:
Reverse relation remove on content save
Details
Install type: Packaged distribution
Database: mysql 5.5.62 - service.mysql via TCP/IP
PHP version: 7.4.11
Symfony version: v5.2.6
Operating System: Linux - 5.4.0-70-generic
Assets version: 4.1.16
Reproduction
On a contentA I define a relation:
On a contentB I define a relation:
When I save contentA with a contentB selected I see the relation in database.
After I save the contentB without or with a contentC selected, the relation between contentA and contentB is removed.
I see in the contentEditController, all the relation is removed before insert new:
I understand why relation is removed but I don't understand why reverse relation are removed too.
So I made a fix which change the bidirectionnal attribute:
$currentRelations = $this->relationRepository->findRelations($content, null, false, null, false);
Do you think there will be side effect ?
The commit in my repo with the modification : novaway@35c7a6e
The text was updated successfully, but these errors were encountered: