Fix duplicate tags creation when assigning search results to tag
Fixes #6330
This commit is contained in:
parent
bfbcee1df5
commit
28db6c22eb
@ -247,10 +247,15 @@ class TagController extends AbstractController
|
|||||||
$filter
|
$filter
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// check to avoid duplicate tags creation
|
||||||
|
foreach ($this->entityManager->getUnitOfWork()->getScheduledEntityInsertions() as $entity) {
|
||||||
|
if ($entity instanceof Tag && strtolower($entity->getLabel()) === strtolower($filter)) {
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
$this->entityManager->persist($entry);
|
$this->entityManager->persist($entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->redirect($this->redirectHelper->to($request->headers->get('referer'), '', true));
|
return $this->redirect($this->redirectHelper->to($request->headers->get('referer'), '', true));
|
||||||
}
|
}
|
||||||
|
@ -560,5 +560,12 @@ class TagControllerTest extends WallabagCoreTestCase
|
|||||||
|
|
||||||
$this->assertContains('title', $tags);
|
$this->assertContains('title', $tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tag = $client->getContainer()
|
||||||
|
->get(EntityManagerInterface::class)
|
||||||
|
->getRepository(Tag::class)
|
||||||
|
->findByLabelsAndUser(['title'], $this->getLoggedInUserId());
|
||||||
|
|
||||||
|
$this->assertCount(1, $tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user