Improved tag edit performance
Post history rewrite happens only when tag has really changed its name.
This commit is contained in:
parent
34e220d465
commit
1b82504f08
1 changed files with 17 additions and 6 deletions
|
@ -128,6 +128,8 @@ class TagService
|
||||||
|
|
||||||
public function updateTag(Tag $tag, TagEditFormData $formData)
|
public function updateTag(Tag $tag, TagEditFormData $formData)
|
||||||
{
|
{
|
||||||
|
$oldName = $tag->getName();
|
||||||
|
|
||||||
$transactionFunc = function() use ($tag, $formData)
|
$transactionFunc = function() use ($tag, $formData)
|
||||||
{
|
{
|
||||||
$this->validator->validate($formData);
|
$this->validator->validate($formData);
|
||||||
|
@ -138,10 +140,18 @@ class TagService
|
||||||
if ($formData->banned !== $tag->isBanned())
|
if ($formData->banned !== $tag->isBanned())
|
||||||
$tag->setBanned(boolval($formData->banned));
|
$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);
|
return $this->tagDao->save($tag);
|
||||||
};
|
};
|
||||||
$ret = $this->transactionManager->commit($transactionFunc);
|
$ret = $this->transactionManager->commit($transactionFunc);
|
||||||
|
|
||||||
|
if ($oldName !== $tag->getName())
|
||||||
|
{
|
||||||
$transactionFunc = function() use ($tag)
|
$transactionFunc = function() use ($tag)
|
||||||
{
|
{
|
||||||
$posts = $this->postDao->findByTagName($tag->getName());
|
$posts = $this->postDao->findByTagName($tag->getName());
|
||||||
|
@ -149,6 +159,7 @@ class TagService
|
||||||
$this->historyService->saveSnapshot($this->historyService->getPostChangeSnapshot($post));
|
$this->historyService->saveSnapshot($this->historyService->getPostChangeSnapshot($post));
|
||||||
};
|
};
|
||||||
$this->transactionManager->commit($transactionFunc);
|
$this->transactionManager->commit($transactionFunc);
|
||||||
|
}
|
||||||
|
|
||||||
$this->exportJson();
|
$this->exportJson();
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
Loading…
Reference in a new issue