aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php40
1 files changed, 16 insertions, 24 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 7dbe3f18..b2814ade 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -284,14 +284,13 @@ class ConfigController extends Controller
284 } 284 }
285 285
286 /** 286 /**
287 * Remove all tags for a given user and cleanup orphan tags. 287 * Remove all tags for given tags and a given user and cleanup orphan tags.
288 * 288 *
289 * @param int $userId 289 * @param array $tags
290 * @param int $userId
290 */ 291 */
291 private function removeAllTagsByUserId($userId) 292 private function removeAllTagsByStatusAndUserId($tags, $userId)
292 { 293 {
293 $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findAllTags($userId);
294
295 if (empty($tags)) { 294 if (empty($tags)) {
296 return; 295 return;
297 } 296 }
@@ -317,28 +316,21 @@ class ConfigController extends Controller
317 * 316 *
318 * @param int $userId 317 * @param int $userId
319 */ 318 */
319 private function removeAllTagsByUserId($userId)
320 {
321 $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findAllTags($userId);
322 $this->removeAllTagsByStatusAndUserId($tags, $userId);
323 }
324
325 /**
326 * Remove all tags for a given user and cleanup orphan tags.
327 *
328 * @param int $userId
329 */
320 private function removeTagsForArchivedByUserId($userId) 330 private function removeTagsForArchivedByUserId($userId)
321 { 331 {
322 $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findTagsForArchivedArticles($userId); 332 $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findTagsForArchivedArticles($userId);
323 333 $this->removeAllTagsByStatusAndUserId($tags, $userId);
324 if (empty($tags)) {
325 return;
326 }
327
328 $this->getDoctrine()
329 ->getRepository('WallabagCoreBundle:Entry')
330 ->removeTags($userId, $tags);
331
332 // cleanup orphan tags
333 $em = $this->getDoctrine()->getManager();
334
335 foreach ($tags as $tag) {
336 if (count($tag->getEntries()) === 0) {
337 $em->remove($tag);
338 }
339 }
340
341 $em->flush();
342 } 334 }
343 335
344 private function removeAnnotationsForArchivedByUserId($userId) 336 private function removeAnnotationsForArchivedByUserId($userId)