diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ConfigController.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index faa85d16..e2484064 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php | |||
@@ -251,9 +251,11 @@ class ConfigController extends Controller | |||
251 | // otherwise they won't be removed ... | 251 | // otherwise they won't be removed ... |
252 | if ($this->get('doctrine')->getConnection()->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) { | 252 | if ($this->get('doctrine')->getConnection()->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) { |
253 | $this->getDoctrine()->getRepository('WallabagAnnotationBundle:Annotation')->removeAllByUserId($this->getUser()->getId()); | 253 | $this->getDoctrine()->getRepository('WallabagAnnotationBundle:Annotation')->removeAllByUserId($this->getUser()->getId()); |
254 | $this->removeAllTagsByUserId($this->getUser()->getId()); | ||
255 | } | 254 | } |
256 | 255 | ||
256 | // manually remove tags first to avoid orphan tag | ||
257 | $this->removeAllTagsByUserId($this->getUser()->getId()); | ||
258 | |||
257 | $this->getDoctrine() | 259 | $this->getDoctrine() |
258 | ->getRepository('WallabagCoreBundle:Entry') | 260 | ->getRepository('WallabagCoreBundle:Entry') |
259 | ->removeAllByUserId($this->getUser()->getId()); | 261 | ->removeAllByUserId($this->getUser()->getId()); |
@@ -268,7 +270,7 @@ class ConfigController extends Controller | |||
268 | } | 270 | } |
269 | 271 | ||
270 | /** | 272 | /** |
271 | * Remove all tags for a given user. | 273 | * Remove all tags for a given user and cleanup orphan tags |
272 | * | 274 | * |
273 | * @param int $userId | 275 | * @param int $userId |
274 | */ | 276 | */ |
@@ -283,6 +285,16 @@ class ConfigController extends Controller | |||
283 | $this->getDoctrine() | 285 | $this->getDoctrine() |
284 | ->getRepository('WallabagCoreBundle:Entry') | 286 | ->getRepository('WallabagCoreBundle:Entry') |
285 | ->removeTags($userId, $tags); | 287 | ->removeTags($userId, $tags); |
288 | |||
289 | $em = $this->getDoctrine()->getManager(); | ||
290 | |||
291 | foreach ($tags as $tag) { | ||
292 | if (count($tag->getEntries()) === 0) { | ||
293 | $em->remove($tag); | ||
294 | } | ||
295 | } | ||
296 | |||
297 | $em->flush(); | ||
286 | } | 298 | } |
287 | 299 | ||
288 | /** | 300 | /** |