From 462708c1d85d3091ab55e38d53a4b33552f41553 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 19 Oct 2014 15:32:11 +0200 Subject: [PATCH] Fixed siblings occasionally removing wrong tag --- src/Dao/TagDao.php | 10 ++++++++-- src/Services/TagService.php | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Dao/TagDao.php b/src/Dao/TagDao.php index 4fe18c21..12824575 100644 --- a/src/Dao/TagDao.php +++ b/src/Dao/TagDao.php @@ -60,8 +60,14 @@ class TagDao extends AbstractDao implements ICrudDao ->where('pt2.tagId', $tagId) ->groupBy('tags.id') ->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); } diff --git a/src/Services/TagService.php b/src/Services/TagService.php index 5514095a..c1b7b4a3 100644 --- a/src/Services/TagService.php +++ b/src/Services/TagService.php @@ -192,13 +192,13 @@ class TagService 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)); } 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)); } }