aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/config/config.yml3
-rw-r--r--app/config/parameters.yml.dist3
-rw-r--r--docs/de/developer/maintenance.rst4
-rw-r--r--docs/de/developer/rabbitmq.rst14
-rw-r--r--docs/de/developer/redis.rst16
-rw-r--r--docs/en/developer/maintenance.rst4
-rw-r--r--docs/en/developer/rabbitmq.rst14
-rw-r--r--docs/en/developer/redis.rst16
-rw-r--r--docs/fr/developer/maintenance.rst4
-rw-r--r--docs/fr/developer/rabbitmq.rst14
-rw-r--r--docs/fr/developer/redis.rst16
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php28
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php6
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml5
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml2
-rw-r--r--tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php9
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php27
-rw-r--r--tests/Wallabag/CoreBundle/Controller/TagControllerTest.php33
18 files changed, 137 insertions, 81 deletions
diff --git a/app/config/config.yml b/app/config/config.yml
index 2475ada8..75d7299c 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -46,7 +46,7 @@ wallabag_core:
46 it: 'Italiano' 46 it: 'Italiano'
47 items_on_page: 12 47 items_on_page: 12
48 theme: material 48 theme: material
49 language: en 49 language: '%locale%'
50 rss_limit: 50 50 rss_limit: 50
51 reading_speed: 1 51 reading_speed: 1
52 cache_lifetime: 10 52 cache_lifetime: 10
@@ -77,6 +77,7 @@ doctrine:
77 password: "%database_password%" 77 password: "%database_password%"
78 charset: UTF8 78 charset: UTF8
79 path: "%database_path%" 79 path: "%database_path%"
80 unix_socket: "%database_socket%"
80 server_version: 5.6 81 server_version: 5.6
81 82
82 orm: 83 orm:
diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist
index f2e5bec3..ece4903a 100644
--- a/app/config/parameters.yml.dist
+++ b/app/config/parameters.yml.dist
@@ -18,6 +18,7 @@ parameters:
18 database_password: ~ 18 database_password: ~
19 database_path: "%kernel.root_dir%/../data/db/wallabag.sqlite" 19 database_path: "%kernel.root_dir%/../data/db/wallabag.sqlite"
20 database_table_prefix: wallabag_ 20 database_table_prefix: wallabag_
21 database_socket: null
21 22
22 mailer_transport: smtp 23 mailer_transport: smtp
23 mailer_host: 127.0.0.1 24 mailer_host: 127.0.0.1
@@ -48,5 +49,7 @@ parameters:
48 rabbitmq_password: guest 49 rabbitmq_password: guest
49 50
50 # Redis processing 51 # Redis processing
52 redis_scheme: tcp
51 redis_host: localhost 53 redis_host: localhost
52 redis_port: 6379 54 redis_port: 6379
55 redis_path: null
diff --git a/docs/de/developer/maintenance.rst b/docs/de/developer/maintenance.rst
index 2a9070e1..31343876 100644
--- a/docs/de/developer/maintenance.rst
+++ b/docs/de/developer/maintenance.rst
@@ -11,7 +11,7 @@ Um den Wartungsmodus zu aktivieren, führe folgendes Kommando aus:
11 11
12:: 12::
13 13
14 bin/console lexik:maintenance:lock --no-interaction 14 bin/console lexik:maintenance:lock -e=prod --no-interaction
15 15
16Du kannst deine IP Adresse in ``app/config/config.yml`` setzen, wenn du Zugriff zu wallabag haben willst, auch wenn der Wartungsmodus aktiv ist. Zum Beispiel: 16Du kannst deine IP Adresse in ``app/config/config.yml`` setzen, wenn du Zugriff zu wallabag haben willst, auch wenn der Wartungsmodus aktiv ist. Zum Beispiel:
17 17
@@ -29,4 +29,4 @@ Um den Wartungsmodus zu deaktivieren, führe dieses Kommando aus:
29 29
30:: 30::
31 31
32 bin/console lexik:maintenance:unlock 32 bin/console lexik:maintenance:unlock -e=prod
diff --git a/docs/de/developer/rabbitmq.rst b/docs/de/developer/rabbitmq.rst
index bea02ff4..37e9984b 100644
--- a/docs/de/developer/rabbitmq.rst
+++ b/docs/de/developer/rabbitmq.rst
@@ -55,23 +55,23 @@ Abhängig von welchem Service du importieren möchtest, solltest du einen Cron J
55.. code:: bash 55.. code:: bash
56 56
57 # for Pocket import 57 # for Pocket import
58 bin/console rabbitmq:consumer import_pocket -w 58 bin/console rabbitmq:consumer -e=prod import_pocket -w
59 59
60 # for Readability import 60 # for Readability import
61 bin/console rabbitmq:consumer import_readability -w 61 bin/console rabbitmq:consumer -e=prod import_readability -w
62 62
63 # for Instapaper import 63 # for Instapaper import
64 bin/console rabbitmq:consumer import_instapaper -w 64 bin/console rabbitmq:consumer -e=prod import_instapaper -w
65 65
66 # for wallabag v1 import 66 # for wallabag v1 import
67 bin/console rabbitmq:consumer import_wallabag_v1 -w 67 bin/console rabbitmq:consumer -e=prod import_wallabag_v1 -w
68 68
69 # for wallabag v2 import 69 # for wallabag v2 import
70 bin/console rabbitmq:consumer import_wallabag_v2 -w 70 bin/console rabbitmq:consumer -e=prod import_wallabag_v2 -w
71 71
72 # for Firefox import 72 # for Firefox import
73 bin/console rabbitmq:consumer import_firefox -w 73 bin/console rabbitmq:consumer -e=prod import_firefox -w
74 74
75 # for Chrome import 75 # for Chrome import
76 bin/console rabbitmq:consumer import_chrome -w 76 bin/console rabbitmq:consumer -e=prod import_chrome -w
77 77
diff --git a/docs/de/developer/redis.rst b/docs/de/developer/redis.rst
index d613ce6c..46334cf0 100644
--- a/docs/de/developer/redis.rst
+++ b/docs/de/developer/redis.rst
@@ -44,28 +44,28 @@ Abhängig von welchem Service du importieren möchtest, solltest du einen Cron J
44.. code:: bash 44.. code:: bash
45 45
46 # for Pocket import 46 # for Pocket import
47 bin/console wallabag:import:redis-worker pocket -vv >> /path/to/wallabag/var/logs/redis-pocket.log 47 bin/console wallabag:import:redis-worker -e=prod pocket -vv >> /path/to/wallabag/var/logs/redis-pocket.log
48 48
49 # for Readability import 49 # for Readability import
50 bin/console wallabag:import:redis-worker readability -vv >> /path/to/wallabag/var/logs/redis-readability.log 50 bin/console wallabag:import:redis-worker -e=prod readability -vv >> /path/to/wallabag/var/logs/redis-readability.log
51 51
52 # for Instapaper import 52 # for Instapaper import
53 bin/console wallabag:import:redis-worker instapaper -vv >> /path/to/wallabag/var/logs/redis-instapaper.log 53 bin/console wallabag:import:redis-worker -e=prod instapaper -vv >> /path/to/wallabag/var/logs/redis-instapaper.log
54 54
55 # for wallabag v1 import 55 # for wallabag v1 import
56 bin/console wallabag:import:redis-worker wallabag_v1 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v1.log 56 bin/console wallabag:import:redis-worker -e=prod wallabag_v1 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v1.log
57 57
58 # for wallabag v2 import 58 # for wallabag v2 import
59 bin/console wallabag:import:redis-worker wallabag_v2 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v2.log 59 bin/console wallabag:import:redis-worker -e=prod wallabag_v2 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v2.log
60 60
61 # for Firefox import 61 # for Firefox import
62 bin/console wallabag:import:redis-worker firefox -vv >> /path/to/wallabag/var/logs/redis-firefox.log 62 bin/console wallabag:import:redis-worker -e=prod firefox -vv >> /path/to/wallabag/var/logs/redis-firefox.log
63 63
64 # for Chrome import 64 # for Chrome import
65 bin/console wallabag:import:redis-worker instapaper -vv >> /path/to/wallabag/var/logs/redis-chrome.log 65 bin/console wallabag:import:redis-worker -e=prod instapaper -vv >> /path/to/wallabag/var/logs/redis-chrome.log
66 66
67Wenn du den Import nur für ein paar Nachrichten und nicht für alle starten willst, kannst du die Nummer (im folgenden Beispiel 12) angeben. Der Redis Worker wird dann nach der 12. Nachricht stoppen: 67Wenn du den Import nur für ein paar Nachrichten und nicht für alle starten willst, kannst du die Nummer (im folgenden Beispiel 12) angeben. Der Redis Worker wird dann nach der 12. Nachricht stoppen:
68 68
69.. code:: bash 69.. code:: bash
70 70
71 bin/console wallabag:import:redis-worker pocket -vv --maxIterations=12 71 bin/console wallabag:import:redis-worker -e=prod pocket -vv --maxIterations=12
diff --git a/docs/en/developer/maintenance.rst b/docs/en/developer/maintenance.rst
index 8277fb1f..6d55ed60 100644
--- a/docs/en/developer/maintenance.rst
+++ b/docs/en/developer/maintenance.rst
@@ -11,7 +11,7 @@ To enable maintenance mode, execute this command:
11 11
12:: 12::
13 13
14 bin/console lexik:maintenance:lock --no-interaction 14 bin/console lexik:maintenance:lock --no-interaction -e=prod
15 15
16You can set your IP address in ``app/config/config.yml`` if you want to access to wallabag even if maintenance mode is enabled. For example: 16You can set your IP address in ``app/config/config.yml`` if you want to access to wallabag even if maintenance mode is enabled. For example:
17 17
@@ -29,4 +29,4 @@ To disable maintenance mode, execute this command:
29 29
30:: 30::
31 31
32 bin/console lexik:maintenance:unlock 32 bin/console lexik:maintenance:unlock -e=prod
diff --git a/docs/en/developer/rabbitmq.rst b/docs/en/developer/rabbitmq.rst
index 63b85106..ca0b0f3a 100644
--- a/docs/en/developer/rabbitmq.rst
+++ b/docs/en/developer/rabbitmq.rst
@@ -55,22 +55,22 @@ Depending on which service you want to import from you need to enable one (or ma
55.. code:: bash 55.. code:: bash
56 56
57 # for Pocket import 57 # for Pocket import
58 bin/console rabbitmq:consumer import_pocket -w 58 bin/console rabbitmq:consumer -e=prod import_pocket -w
59 59
60 # for Readability import 60 # for Readability import
61 bin/console rabbitmq:consumer import_readability -w 61 bin/console rabbitmq:consumer -e=prod import_readability -w
62 62
63 # for Instapaper import 63 # for Instapaper import
64 bin/console rabbitmq:consumer import_instapaper -w 64 bin/console rabbitmq:consumer -e=prod import_instapaper -w
65 65
66 # for wallabag v1 import 66 # for wallabag v1 import
67 bin/console rabbitmq:consumer import_wallabag_v1 -w 67 bin/console rabbitmq:consumer -e=prod import_wallabag_v1 -w
68 68
69 # for wallabag v2 import 69 # for wallabag v2 import
70 bin/console rabbitmq:consumer import_wallabag_v2 -w 70 bin/console rabbitmq:consumer -e=prod import_wallabag_v2 -w
71 71
72 # for Firefox import 72 # for Firefox import
73 bin/console rabbitmq:consumer import_firefox -w 73 bin/console rabbitmq:consumer -e=prod import_firefox -w
74 74
75 # for Chrome import 75 # for Chrome import
76 bin/console rabbitmq:consumer import_chrome -w 76 bin/console rabbitmq:consumer -e=prod import_chrome -w
diff --git a/docs/en/developer/redis.rst b/docs/en/developer/redis.rst
index 820a52e9..005d6e4f 100644
--- a/docs/en/developer/redis.rst
+++ b/docs/en/developer/redis.rst
@@ -44,28 +44,28 @@ Depending on which service you want to import from you need to enable one (or ma
44.. code:: bash 44.. code:: bash
45 45
46 # for Pocket import 46 # for Pocket import
47 bin/console wallabag:import:redis-worker pocket -vv >> /path/to/wallabag/var/logs/redis-pocket.log 47 bin/console wallabag:import:redis-worker -e=prod pocket -vv >> /path/to/wallabag/var/logs/redis-pocket.log
48 48
49 # for Readability import 49 # for Readability import
50 bin/console wallabag:import:redis-worker readability -vv >> /path/to/wallabag/var/logs/redis-readability.log 50 bin/console wallabag:import:redis-worker -e=prod readability -vv >> /path/to/wallabag/var/logs/redis-readability.log
51 51
52 # for Instapaper import 52 # for Instapaper import
53 bin/console wallabag:import:redis-worker instapaper -vv >> /path/to/wallabag/var/logs/redis-instapaper.log 53 bin/console wallabag:import:redis-worker -e=prod instapaper -vv >> /path/to/wallabag/var/logs/redis-instapaper.log
54 54
55 # for wallabag v1 import 55 # for wallabag v1 import
56 bin/console wallabag:import:redis-worker wallabag_v1 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v1.log 56 bin/console wallabag:import:redis-worker -e=prod wallabag_v1 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v1.log
57 57
58 # for wallabag v2 import 58 # for wallabag v2 import
59 bin/console wallabag:import:redis-worker wallabag_v2 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v2.log 59 bin/console wallabag:import:redis-worker -e=prod wallabag_v2 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v2.log
60 60
61 # for Firefox import 61 # for Firefox import
62 bin/console wallabag:import:redis-worker firefox -vv >> /path/to/wallabag/var/logs/redis-firefox.log 62 bin/console wallabag:import:redis-worker -e=prod firefox -vv >> /path/to/wallabag/var/logs/redis-firefox.log
63 63
64 # for Chrome import 64 # for Chrome import
65 bin/console wallabag:import:redis-worker instapaper -vv >> /path/to/wallabag/var/logs/redis-chrome.log 65 bin/console wallabag:import:redis-worker -e=prod instapaper -vv >> /path/to/wallabag/var/logs/redis-chrome.log
66 66
67If you want to launch the import only for some messages and not all, you can specify this number (here 12) and the worker will stop right after the 12th message : 67If you want to launch the import only for some messages and not all, you can specify this number (here 12) and the worker will stop right after the 12th message :
68 68
69.. code:: bash 69.. code:: bash
70 70
71 bin/console wallabag:import:redis-worker pocket -vv --maxIterations=12 71 bin/console wallabag:import:redis-worker -e=prod pocket -vv --maxIterations=12
diff --git a/docs/fr/developer/maintenance.rst b/docs/fr/developer/maintenance.rst
index 4ea8d01f..8007a85f 100644
--- a/docs/fr/developer/maintenance.rst
+++ b/docs/fr/developer/maintenance.rst
@@ -11,7 +11,7 @@ Pour activer le mode maintenance, exécutez cette commande :
11 11
12:: 12::
13 13
14 bin/console lexik:maintenance:lock --no-interaction 14 bin/console lexik:maintenance:lock --no-interaction -e=prod
15 15
16Vous pouvez spécifier votre adresse IP dans ``app/config/config.yml`` si vous souhaitez accéder à wallabag même si 16Vous pouvez spécifier votre adresse IP dans ``app/config/config.yml`` si vous souhaitez accéder à wallabag même si
17 le mode maintenance est activé. Par exemple : 17 le mode maintenance est activé. Par exemple :
@@ -30,4 +30,4 @@ Pour désactiver le mode maintenance, exécutez cette commande :
30 30
31:: 31::
32 32
33 bin/console lexik:maintenance:unlock 33 bin/console lexik:maintenance:unlock -e=prod
diff --git a/docs/fr/developer/rabbitmq.rst b/docs/fr/developer/rabbitmq.rst
index 20182e6e..771725a7 100644
--- a/docs/fr/developer/rabbitmq.rst
+++ b/docs/fr/developer/rabbitmq.rst
@@ -55,22 +55,22 @@ En fonction du service dont vous souhaitez importer vos données, vous devez act
55.. code:: bash 55.. code:: bash
56 56
57 # for Pocket import 57 # for Pocket import
58 bin/console rabbitmq:consumer import_pocket -w 58 bin/console rabbitmq:consumer -e=prod import_pocket -w
59 59
60 # for Readability import 60 # for Readability import
61 bin/console rabbitmq:consumer import_readability -w 61 bin/console rabbitmq:consumer -e=prod import_readability -w
62 62
63 # for Instapaper import 63 # for Instapaper import
64 bin/console rabbitmq:consumer import_instapaper -w 64 bin/console rabbitmq:consumer -e=prod import_instapaper -w
65 65
66 # for wallabag v1 import 66 # for wallabag v1 import
67 bin/console rabbitmq:consumer import_wallabag_v1 -w 67 bin/console rabbitmq:consumer -e=prod import_wallabag_v1 -w
68 68
69 # for wallabag v2 import 69 # for wallabag v2 import
70 bin/console rabbitmq:consumer import_wallabag_v2 -w 70 bin/console rabbitmq:consumer -e=prod import_wallabag_v2 -w
71 71
72 # for Firefox import 72 # for Firefox import
73 bin/console rabbitmq:consumer import_firefox -w 73 bin/console rabbitmq:consumer -e=prod import_firefox -w
74 74
75 # for Chrome import 75 # for Chrome import
76 bin/console rabbitmq:consumer import_chrome -w 76 bin/console rabbitmq:consumer -e=prod import_chrome -w
diff --git a/docs/fr/developer/redis.rst b/docs/fr/developer/redis.rst
index 097e375d..5557e7a8 100644
--- a/docs/fr/developer/redis.rst
+++ b/docs/fr/developer/redis.rst
@@ -44,28 +44,28 @@ En fonction du service dont vous souhaitez importer vos données, vous devez act
44.. code:: bash 44.. code:: bash
45 45
46 # for Pocket import 46 # for Pocket import
47 bin/console wallabag:import:redis-worker pocket -vv >> /path/to/wallabag/var/logs/redis-pocket.log 47 bin/console wallabag:import:redis-worker -e=prod pocket -vv >> /path/to/wallabag/var/logs/redis-pocket.log
48 48
49 # for Readability import 49 # for Readability import
50 bin/console wallabag:import:redis-worker readability -vv >> /path/to/wallabag/var/logs/redis-readability.log 50 bin/console wallabag:import:redis-worker -e=prod readability -vv >> /path/to/wallabag/var/logs/redis-readability.log
51 51
52 # for Instapaper import 52 # for Instapaper import
53 bin/console wallabag:import:redis-worker instapaper -vv >> /path/to/wallabag/var/logs/redis-instapaper.log 53 bin/console wallabag:import:redis-worker -e=prod instapaper -vv >> /path/to/wallabag/var/logs/redis-instapaper.log
54 54
55 # for wallabag v1 import 55 # for wallabag v1 import
56 bin/console wallabag:import:redis-worker wallabag_v1 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v1.log 56 bin/console wallabag:import:redis-worker -e=prod wallabag_v1 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v1.log
57 57
58 # for wallabag v2 import 58 # for wallabag v2 import
59 bin/console wallabag:import:redis-worker wallabag_v2 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v2.log 59 bin/console wallabag:import:redis-worker -e=prod wallabag_v2 -vv >> /path/to/wallabag/var/logs/redis-wallabag_v2.log
60 60
61 # for Firefox import 61 # for Firefox import
62 bin/console wallabag:import:redis-worker firefox -vv >> /path/to/wallabag/var/logs/redis-firefox.log 62 bin/console wallabag:import:redis-worker -e=prod firefox -vv >> /path/to/wallabag/var/logs/redis-firefox.log
63 63
64 # for Chrome import 64 # for Chrome import
65 bin/console wallabag:import:redis-worker instapaper -vv >> /path/to/wallabag/var/logs/redis-chrome.log 65 bin/console wallabag:import:redis-worker -e=prod instapaper -vv >> /path/to/wallabag/var/logs/redis-chrome.log
66 66
67Si vous souhaitez démarrer l'import pour quelques messages uniquement, vous pouvez spécifier cette valeur en paramètre (ici 12) et le client va s'arrêter après le 12ème message : 67Si vous souhaitez démarrer l'import pour quelques messages uniquement, vous pouvez spécifier cette valeur en paramètre (ici 12) et le client va s'arrêter après le 12ème message :
68 68
69.. code:: bash 69.. code:: bash
70 70
71 bin/console wallabag:import:redis-worker pocket -vv --maxIterations=12 71 bin/console wallabag:import:redis-worker -e=prod pocket -vv --maxIterations=12
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index 6dd03c1b..ed31c536 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -420,6 +420,8 @@ class WallabagRestController extends FOSRestController
420 ->getRepository('WallabagCoreBundle:Entry') 420 ->getRepository('WallabagCoreBundle:Entry')
421 ->removeTag($this->getUser()->getId(), $tag); 421 ->removeTag($this->getUser()->getId(), $tag);
422 422
423 $this->cleanOrphanTag($tag);
424
423 $json = $this->get('serializer')->serialize($tag, 'json'); 425 $json = $this->get('serializer')->serialize($tag, 'json');
424 426
425 return (new JsonResponse())->setJson($json); 427 return (new JsonResponse())->setJson($json);
@@ -460,6 +462,8 @@ class WallabagRestController extends FOSRestController
460 ->getRepository('WallabagCoreBundle:Entry') 462 ->getRepository('WallabagCoreBundle:Entry')
461 ->removeTags($this->getUser()->getId(), $tags); 463 ->removeTags($this->getUser()->getId(), $tags);
462 464
465 $this->cleanOrphanTag($tags);
466
463 $json = $this->get('serializer')->serialize($tags, 'json'); 467 $json = $this->get('serializer')->serialize($tags, 'json');
464 468
465 return (new JsonResponse())->setJson($json); 469 return (new JsonResponse())->setJson($json);
@@ -484,6 +488,8 @@ class WallabagRestController extends FOSRestController
484 ->getRepository('WallabagCoreBundle:Entry') 488 ->getRepository('WallabagCoreBundle:Entry')
485 ->removeTag($this->getUser()->getId(), $tag); 489 ->removeTag($this->getUser()->getId(), $tag);
486 490
491 $this->cleanOrphanTag($tag);
492
487 $json = $this->get('serializer')->serialize($tag, 'json'); 493 $json = $this->get('serializer')->serialize($tag, 'json');
488 494
489 return (new JsonResponse())->setJson($json); 495 return (new JsonResponse())->setJson($json);
@@ -506,6 +512,28 @@ class WallabagRestController extends FOSRestController
506 } 512 }
507 513
508 /** 514 /**
515 * Remove orphan tag in case no entries are associated to it.
516 *
517 * @param Tag|array $tags
518 */
519 private function cleanOrphanTag($tags)
520 {
521 if (!is_array($tags)) {
522 $tags = [$tags];
523 }
524
525 $em = $this->getDoctrine()->getManager();
526
527 foreach ($tags as $tag) {
528 if (count($tag->getEntries()) === 0) {
529 $em->remove($tag);
530 }
531 }
532
533 $em->flush();
534 }
535
536 /**
509 * Validate that the first id is equal to the second one. 537 * Validate that the first id is equal to the second one.
510 * If not, throw exception. It means a user try to access information from an other user. 538 * If not, throw exception. It means a user try to access information from an other user.
511 * 539 *
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index 623a6146..c5746734 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -63,10 +63,12 @@ class TagController extends Controller
63 $entry->removeTag($tag); 63 $entry->removeTag($tag);
64 $em = $this->getDoctrine()->getManager(); 64 $em = $this->getDoctrine()->getManager();
65 $em->flush(); 65 $em->flush();
66 if (count($tag->getEntries()) == 0) { 66
67 // remove orphan tag in case no entries are associated to it
68 if (count($tag->getEntries()) === 0) {
67 $em->remove($tag); 69 $em->remove($tag);
70 $em->flush();
68 } 71 }
69 $em->flush();
70 72
71 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer')); 73 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'));
72 74
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index d1139846..a4b727f4 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -29,7 +29,7 @@ services:
29 arguments: 29 arguments:
30 - "@doctrine" 30 - "@doctrine"
31 31
32 wallabag_core.table_prefix_subscriber: 32 wallabag_core.subscriber.table_prefix:
33 class: Wallabag\CoreBundle\Subscriber\TablePrefixSubscriber 33 class: Wallabag\CoreBundle\Subscriber\TablePrefixSubscriber
34 arguments: 34 arguments:
35 - "%database_table_prefix%" 35 - "%database_table_prefix%"
@@ -119,9 +119,10 @@ services:
119 class: Predis\Client 119 class: Predis\Client
120 arguments: 120 arguments:
121 - 121 -
122 scheme: '%redis_scheme%'
122 host: '%redis_host%' 123 host: '%redis_host%'
123 port: '%redis_port%' 124 port: '%redis_port%'
124 schema: tcp 125 path: '%redis_path%'
125 126
126 wallabag_core.exception_controller: 127 wallabag_core.exception_controller:
127 class: Wallabag\CoreBundle\Controller\ExceptionController 128 class: Wallabag\CoreBundle\Controller\ExceptionController
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index 9791a3b2..547e9c8b 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -209,7 +209,7 @@ entry:
209 is_public_label: 'Publiczny' 209 is_public_label: 'Publiczny'
210 save_label: 'Zapisz' 210 save_label: 'Zapisz'
211 public: 211 public:
212 # shared_by_wallabag: "This article has been shared by <a href='%wallabag_instance%'>wallabag</a>" 212 shared_by_wallabag: "Ten artykuł został udostępniony przez <a href='%wallabag_instance%'>wallabag</a>"
213 213
214about: 214about:
215 page_title: 'O nas' 215 page_title: 'O nas'
diff --git a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
index 4f16e70f..5dcb3e00 100644
--- a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
@@ -561,6 +561,8 @@ class WallabagRestControllerTest extends WallabagApiTestCase
561 */ 561 */
562 public function testDeleteUserTag($tag) 562 public function testDeleteUserTag($tag)
563 { 563 {
564 $tagName = $tag['label'];
565
564 $this->client->request('DELETE', '/api/tags/'.$tag['id'].'.json'); 566 $this->client->request('DELETE', '/api/tags/'.$tag['id'].'.json');
565 567
566 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 568 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@@ -577,6 +579,13 @@ class WallabagRestControllerTest extends WallabagApiTestCase
577 ->findAllByTagId($this->user->getId(), $tag['id']); 579 ->findAllByTagId($this->user->getId(), $tag['id']);
578 580
579 $this->assertCount(0, $entries); 581 $this->assertCount(0, $entries);
582
583 $tag = $this->client->getContainer()
584 ->get('doctrine.orm.entity_manager')
585 ->getRepository('WallabagCoreBundle:Tag')
586 ->findOneByLabel($tagName);
587
588 $this->assertNull($tag, $tagName.' was removed because it begun an orphan tag');
580 } 589 }
581 590
582 public function testDeleteTagByLabel() 591 public function testDeleteTagByLabel()
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index d7bf03ba..9b03a519 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -341,22 +341,23 @@ class EntryControllerTest extends WallabagCoreTestCase
341 $this->logInAs('admin'); 341 $this->logInAs('admin');
342 $client = $this->getClient(); 342 $client = $this->getClient();
343 343
344 $content = $client->getContainer() 344 $em = $client->getContainer()
345 ->get('doctrine.orm.entity_manager') 345 ->get('doctrine.orm.entity_manager');
346
347 $content = $em
346 ->getRepository('WallabagCoreBundle:Entry') 348 ->getRepository('WallabagCoreBundle:Entry')
347 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); 349 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
348 350
349 // empty content 351 // empty content
350 $content->setContent(''); 352 $content->setContent('');
351 $client->getContainer()->get('doctrine.orm.entity_manager')->persist($content); 353 $em->persist($content);
352 $client->getContainer()->get('doctrine.orm.entity_manager')->flush(); 354 $em->flush();
353 355
354 $client->request('GET', '/reload/'.$content->getId()); 356 $client->request('GET', '/reload/'.$content->getId());
355 357
356 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 358 $this->assertEquals(302, $client->getResponse()->getStatusCode());
357 359
358 $content = $client->getContainer() 360 $content = $em
359 ->get('doctrine.orm.entity_manager')
360 ->getRepository('WallabagCoreBundle:Entry') 361 ->getRepository('WallabagCoreBundle:Entry')
361 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); 362 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
362 363
@@ -486,9 +487,11 @@ class EntryControllerTest extends WallabagCoreTestCase
486 $this->logInAs('admin'); 487 $this->logInAs('admin');
487 $client = $this->getClient(); 488 $client = $this->getClient();
488 489
490 $em = $client->getContainer()
491 ->get('doctrine.orm.entity_manager');
492
489 // add a new content to be removed later 493 // add a new content to be removed later
490 $user = $client->getContainer() 494 $user = $em
491 ->get('doctrine.orm.entity_manager')
492 ->getRepository('WallabagUserBundle:User') 495 ->getRepository('WallabagUserBundle:User')
493 ->findOneByUserName('admin'); 496 ->findOneByUserName('admin');
494 497
@@ -502,12 +505,8 @@ class EntryControllerTest extends WallabagCoreTestCase
502 $content->setArchived(true); 505 $content->setArchived(true);
503 $content->setLanguage('fr'); 506 $content->setLanguage('fr');
504 507
505 $client->getContainer() 508 $em->persist($content);
506 ->get('doctrine.orm.entity_manager') 509 $em->flush();
507 ->persist($content);
508 $client->getContainer()
509 ->get('doctrine.orm.entity_manager')
510 ->flush();
511 510
512 $client->request('GET', '/view/'.$content->getId()); 511 $client->request('GET', '/view/'.$content->getId());
513 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 512 $this->assertEquals(200, $client->getResponse()->getStatusCode());
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
index 86a6cca2..769ce66e 100644
--- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
@@ -3,6 +3,7 @@
3namespace Tests\Wallabag\CoreBundle\Controller; 3namespace Tests\Wallabag\CoreBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Wallabag\CoreBundle\Entity\Tag;
6 7
7class TagControllerTest extends WallabagCoreTestCase 8class TagControllerTest extends WallabagCoreTestCase
8{ 9{
@@ -134,36 +135,48 @@ class TagControllerTest extends WallabagCoreTestCase
134 $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId()); 135 $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId());
135 136
136 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 137 $this->assertEquals(404, $client->getResponse()->getStatusCode());
138
139 $tag = $client->getContainer()
140 ->get('doctrine.orm.entity_manager')
141 ->getRepository('WallabagCoreBundle:Tag')
142 ->findOneByLabel($this->tagName);
143
144 $this->assertNull($tag, $this->tagName.' was removed because it begun an orphan tag');
137 } 145 }
138 146
139 public function testShowEntriesForTagAction() 147 public function testShowEntriesForTagAction()
140 { 148 {
141 $this->logInAs('admin'); 149 $this->logInAs('admin');
142 $client = $this->getClient(); 150 $client = $this->getClient();
151 $em = $client->getContainer()
152 ->get('doctrine.orm.entity_manager');
153
154 $tag = new Tag();
155 $tag->setLabel($this->tagName);
143 156
144 $entry = $client->getContainer() 157 $entry = $client->getContainer()
145 ->get('doctrine.orm.entity_manager') 158 ->get('doctrine.orm.entity_manager')
146 ->getRepository('WallabagCoreBundle:Entry') 159 ->getRepository('WallabagCoreBundle:Entry')
147 ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getLoggedInUserId()); 160 ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getLoggedInUserId());
148 161
149 $tag = $client->getContainer() 162 $tag->addEntry($entry);
150 ->get('doctrine.orm.entity_manager')
151 ->getRepository('WallabagCoreBundle:Tag')
152 ->findOneByEntryAndTagLabel($entry, 'foo');
153
154 $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug());
155 163
156 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 164 $em->persist($entry);
157 $this->assertCount(2, $crawler->filter('div[class=entry]')); 165 $em->persist($tag);
166 $em->flush();
158 167
159 $tag = $client->getContainer() 168 $tag = $client->getContainer()
160 ->get('doctrine.orm.entity_manager') 169 ->get('doctrine.orm.entity_manager')
161 ->getRepository('WallabagCoreBundle:Tag') 170 ->getRepository('WallabagCoreBundle:Tag')
162 ->findOneByLabel('baz'); 171 ->findOneByEntryAndTagLabel($entry, $this->tagName);
163 172
164 $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug()); 173 $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug());
165 174
166 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 175 $this->assertEquals(200, $client->getResponse()->getStatusCode());
167 $this->assertCount(1, $crawler->filter('div[class=entry]')); 176 $this->assertCount(1, $crawler->filter('[id*="entry-"]'));
177
178 $entry->removeTag($tag);
179 $em->remove($tag);
180 $em->flush();
168 } 181 }
169} 182}