aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-09-25 16:11:06 +0200
committerGitHub <noreply@github.com>2016-09-25 16:11:06 +0200
commit7e98ad962680fac17b3b90ae34b9c6e5afe7636f (patch)
tree451f2c7ec7011f1f0ee8911fb1921b02f158e1dc /src/Wallabag/CoreBundle/Twig/WallabagExtension.php
parent9d7dd6b0d2480d3efff5b0ab1461f2ef99bfd57a (diff)
parent289875836a09944f5993d33753042abfef13809e (diff)
downloadwallabag-7e98ad962680fac17b3b90ae34b9c6e5afe7636f.tar.gz
wallabag-7e98ad962680fac17b3b90ae34b9c6e5afe7636f.tar.zst
wallabag-7e98ad962680fac17b3b90ae34b9c6e5afe7636f.zip
Merge pull request #2308 from wallabag/tags-duplicate
Fix duplicate tags on import
Diffstat (limited to 'src/Wallabag/CoreBundle/Twig/WallabagExtension.php')
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php31
1 files changed, 5 insertions, 26 deletions
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
index 3780b13e..fb4c7412 100644
--- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
+++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
@@ -2,7 +2,6 @@
2 2
3namespace Wallabag\CoreBundle\Twig; 3namespace Wallabag\CoreBundle\Twig;
4 4
5use Doctrine\ORM\Query;
6use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
7use Wallabag\CoreBundle\Repository\EntryRepository; 6use Wallabag\CoreBundle\Repository\EntryRepository;
8use Wallabag\CoreBundle\Repository\TagRepository; 7use Wallabag\CoreBundle\Repository\TagRepository;
@@ -85,10 +84,11 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
85 ->groupBy('e.id') 84 ->groupBy('e.id')
86 ->getQuery(); 85 ->getQuery();
87 86
88 $data = $this->enableCache($query) 87 $query->useQueryCache(true);
89 ->getArrayResult(); 88 $query->useResultCache(true);
89 $query->setResultCacheLifetime($this->lifeTime);
90 90
91 return count($data); 91 return count($query->getArrayResult());
92 } 92 }
93 93
94 /** 94 /**
@@ -104,28 +104,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
104 return 0; 104 return 0;
105 } 105 }
106 106
107 $qb = $this->tagRepository->findAllTags($user->getId()); 107 return $this->tagRepository->countAllTags($user->getId());
108
109 $data = $this->enableCache($qb->getQuery())
110 ->getArrayResult();
111
112 return count($data);
113 }
114
115 /**
116 * Enable cache for a query.
117 *
118 * @param Query $query
119 *
120 * @return Query
121 */
122 private function enableCache(Query $query)
123 {
124 $query->useQueryCache(true);
125 $query->useResultCache(true);
126 $query->setResultCacheLifetime($this->lifeTime);
127
128 return $query;
129 } 108 }
130 109
131 public function getName() 110 public function getName()