Improved tag edit performance

Post history rewrite happens only when tag has really changed its name.
This commit is contained in:
Marcin Kurczewski 2014-10-15 20:03:32 +02:00
parent 34e220d465
commit 1b82504f08

View file

@ -128,6 +128,8 @@ class TagService
public function updateTag(Tag $tag, TagEditFormData $formData)
{
$oldName = $tag->getName();
$transactionFunc = function() use ($tag, $formData)
{
$this->validator->validate($formData);
@ -138,10 +140,18 @@ class TagService
if ($formData->banned !== $tag->isBanned())
$tag->setBanned(boolval($formData->banned));
if ($formData->implications !== null)
$this->updateImplications($tag, $formData->implications);
if ($formData->suggestions !== null)
$this->updateSuggestions($tag, $formData->suggestions);
return $this->tagDao->save($tag);
};
$ret = $this->transactionManager->commit($transactionFunc);
if ($oldName !== $tag->getName())
{
$transactionFunc = function() use ($tag)
{
$posts = $this->postDao->findByTagName($tag->getName());
@ -149,6 +159,7 @@ class TagService
$this->historyService->saveSnapshot($this->historyService->getPostChangeSnapshot($post));
};
$this->transactionManager->commit($transactionFunc);
}
$this->exportJson();
return $ret;