forked from wallabag/wallabag
Fix tags count in menu
Move enable cache for Tag in the Entity because function `find*` should return result and not a Query
This commit is contained in:
@ -85,10 +85,11 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
|
||||
->groupBy('e.id')
|
||||
->getQuery();
|
||||
|
||||
$data = $this->enableCache($query)
|
||||
->getArrayResult();
|
||||
$query->useQueryCache(true);
|
||||
$query->useResultCache(true);
|
||||
$query->setResultCacheLifetime($this->lifeTime);
|
||||
|
||||
return count($data);
|
||||
return count($query->getArrayResult());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,30 +105,11 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
|
||||
return 0;
|
||||
}
|
||||
|
||||
$qb = $this->tagRepository->findAllTags($user->getId());
|
||||
|
||||
$data = $this->enableCache($qb->getQuery())
|
||||
->getArrayResult();
|
||||
$data = $this->tagRepository->findAllTags($user->getId());
|
||||
|
||||
return count($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable cache for a query.
|
||||
*
|
||||
* @param Query $query
|
||||
*
|
||||
* @return Query
|
||||
*/
|
||||
private function enableCache(Query $query)
|
||||
{
|
||||
$query->useQueryCache(true);
|
||||
$query->useResultCache(true);
|
||||
$query->setResultCacheLifetime($this->lifeTime);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'wallabag_extension';
|
||||
|
||||
Reference in New Issue
Block a user