Fixed siblings occasionally removing wrong tag

This commit is contained in:
Marcin Kurczewski 2014-10-19 15:32:11 +02:00
parent 8509b5fb00
commit 462708c1d8
2 changed files with 10 additions and 4 deletions

View file

@ -60,8 +60,14 @@ class TagDao extends AbstractDao implements ICrudDao
->where('pt2.tagId', $tagId) ->where('pt2.tagId', $tagId)
->groupBy('tags.id') ->groupBy('tags.id')
->orderBy('postCount DESC, name ASC'); ->orderBy('postCount DESC, name ASC');
$arrayEntities = iterator_to_array($query);
array_shift($arrayEntities); //don't show input tag itself $arrayEntities = array_filter(
iterator_to_array($query),
function($arrayEntity) use ($tagName)
{
return strcasecmp($arrayEntity['name'], $tagName) !== 0;
});
return $this->arrayToEntities($arrayEntities); return $this->arrayToEntities($arrayEntities);
} }

View file

@ -192,13 +192,13 @@ class TagService
private function updateImplications(Tag $tag, array $relatedNames) private function updateImplications(Tag $tag, array $relatedNames)
{ {
$relatedNames = array_udiff($relatedNames, [$tag->getName()], 'strnatcasecmp'); $relatedNames = array_udiff($relatedNames, [$tag->getName()], 'strcasecmp');
$tag->setImpliedTags($this->createTags($relatedNames)); $tag->setImpliedTags($this->createTags($relatedNames));
} }
private function updateSuggestions(Tag $tag, array $relatedNames) private function updateSuggestions(Tag $tag, array $relatedNames)
{ {
$relatedNames = array_udiff($relatedNames, [$tag->getName()], 'strnatcasecmp'); $relatedNames = array_udiff($relatedNames, [$tag->getName()], 'strcasecmp');
$tag->setSuggestedTags($this->createTags($relatedNames)); $tag->setSuggestedTags($this->createTags($relatedNames));
} }
} }