aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php3
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php3
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml1
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml3
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/themes/baggy/Static/about.html.twig2
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/themes/material/Static/about.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php20
-rw-r--r--src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php17
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV1Import.php2
-rw-r--r--src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php2
-rw-r--r--src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php2
12 files changed, 34 insertions, 25 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index aa70307b..9dd904f1 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -49,8 +49,7 @@ class EntryController extends Controller
49 49
50 if ($form->isValid()) { 50 if ($form->isValid()) {
51 // check for existing entry, if it exists, redirect to it with a message 51 // check for existing entry, if it exists, redirect to it with a message
52 $existingEntry = $this->get('wallabag_core.entry_repository') 52 $existingEntry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
53 ->existByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
54 53
55 if (false !== $existingEntry) { 54 if (false !== $existingEntry) {
56 $this->get('session')->getFlashBag()->add( 55 $this->get('session')->getFlashBag()->add(
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index a16be9e0..82eb9474 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -235,10 +235,9 @@ class EntryRepository extends EntityRepository
235 * 235 *
236 * @return array|bool 236 * @return array|bool
237 */ 237 */
238 public function existByUrlAndUserId($url, $userId) 238 public function findByUrlAndUserId($url, $userId)
239 { 239 {
240 $res = $this->createQueryBuilder('e') 240 $res = $this->createQueryBuilder('e')
241 ->select('e.id, e.createdAt')
242 ->where('e.url = :url')->setParameter('url', $url) 241 ->where('e.url = :url')->setParameter('url', $url)
243 ->andWhere('e.user = :user_id')->setParameter('user_id', $userId) 242 ->andWhere('e.user = :user_id')->setParameter('user_id', $userId)
244 ->getQuery() 243 ->getQuery()
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index b9818827..8b75594c 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -93,7 +93,6 @@ or: "oder"
93"by contributing to the project:": "indem du zu dem Projekt beiträgst:" 93"by contributing to the project:": "indem du zu dem Projekt beiträgst:"
94an issue lists all our needs: "ein Issue listet alle unsere Bedürfnisse:" 94an issue lists all our needs: "ein Issue listet alle unsere Bedürfnisse:"
95via Paypal: "via PayPal" 95via Paypal: "via PayPal"
96via Flattr: "via Flattr"
97 96
98# Howto 97# Howto
99Form: Formular 98Form: Formular
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index 941237bf..20f4352b 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -94,7 +94,6 @@ or: "ou"
94"by contributing to the project:": "en contribuant au projet :" 94"by contributing to the project:": "en contribuant au projet :"
95an issue lists all our needs: "un ticket recense tous nos besoins" 95an issue lists all our needs: "un ticket recense tous nos besoins"
96via Paypal: "via Paypal" 96via Paypal: "via Paypal"
97via Flattr: "via Flattr"
98 97
99# Howto 98# Howto
100Form: "Formulaire" 99Form: "Formulaire"
@@ -163,4 +162,4 @@ Support: "Support"
163If you need some help, we are here for you.: "Parce que vous avez peut-être besoin de nous poser une question, nous sommes disponibles pour vous." 162If you need some help, we are here for you.: "Parce que vous avez peut-être besoin de nous poser une question, nous sommes disponibles pour vous."
164On GitHub: "Sur GitHub" 163On GitHub: "Sur GitHub"
165By email: "Par email" 164By email: "Par email"
166On Gitter: "Sur Gitter" \ No newline at end of file 165On Gitter: "Sur Gitter"
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Static/about.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Static/about.html.twig
index 311b5067..38f08da6 100755
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Static/about.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Static/about.html.twig
@@ -41,7 +41,5 @@
41 <dt>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</dt> 41 <dt>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</dt>
42 <dd>by contributing to the project: <a href="https://github.com/wallabag/wallabag/issues/1254">an issue lists all our needs</a></dd> 42 <dd>by contributing to the project: <a href="https://github.com/wallabag/wallabag/issues/1254">an issue lists all our needs</a></dd>
43 <dd><a href="{{ paypal_url }}">{% trans %}via Paypal{% endtrans %}</a></dd> 43 <dd><a href="{{ paypal_url }}">{% trans %}via Paypal{% endtrans %}</a></dd>
44
45 <dd><a href="{{ flattr_url }}">{% trans %}via Flattr{% endtrans %}</a></dd>
46 </dl> 44 </dl>
47{% endblock %} 45{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/about.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/about.html.twig
index ef1fe916..d6b8e28a 100755
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/about.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/about.html.twig
@@ -46,8 +46,6 @@
46 <dt>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</dt> 46 <dt>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</dt>
47 <dd>{% trans %}by contributing to the project:{% endtrans %} <a href="https://github.com/wallabag/wallabag/issues/1254">{% trans %}an issue lists all our needs{% endtrans %}</a></dd> 47 <dd>{% trans %}by contributing to the project:{% endtrans %} <a href="https://github.com/wallabag/wallabag/issues/1254">{% trans %}an issue lists all our needs{% endtrans %}</a></dd>
48 <dd><a href="{{ paypal_url }}">{% trans %}via Paypal{% endtrans %}</a></dd> 48 <dd><a href="{{ paypal_url }}">{% trans %}via Paypal{% endtrans %}</a></dd>
49
50 <dd><a href="{{ flattr_url }}">{% trans %}via Flattr{% endtrans %}</a></dd>
51 </dl> 49 </dl>
52 </div> 50 </div>
53 51
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index 3a775182..1d1620dc 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -38,7 +38,7 @@ class EntryControllerTest extends WallabagCoreTestCase
38 $form = $crawler->filter('button[type=submit]')->form(); 38 $form = $crawler->filter('button[type=submit]')->form();
39 39
40 $data = array( 40 $data = array(
41 'entry[url]' => 'https://www.wallabag.org/blog/2016/01/08/wallabag-alpha1-v2', 41 'entry[url]' => $this->url,
42 ); 42 );
43 43
44 $client->submit($form, $data); 44 $client->submit($form, $data);
@@ -82,7 +82,7 @@ class EntryControllerTest extends WallabagCoreTestCase
82 ->get('doctrine.orm.entity_manager'); 82 ->get('doctrine.orm.entity_manager');
83 $entry = $em 83 $entry = $em
84 ->getRepository('WallabagCoreBundle:Entry') 84 ->getRepository('WallabagCoreBundle:Entry')
85 ->findOneByUrl($this->url); 85 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
86 $em->remove($entry); 86 $em->remove($entry);
87 $em->flush(); 87 $em->flush();
88 } 88 }
@@ -202,7 +202,7 @@ class EntryControllerTest extends WallabagCoreTestCase
202 $content = $client->getContainer() 202 $content = $client->getContainer()
203 ->get('doctrine.orm.entity_manager') 203 ->get('doctrine.orm.entity_manager')
204 ->getRepository('WallabagCoreBundle:Entry') 204 ->getRepository('WallabagCoreBundle:Entry')
205 ->findOneByUrl($this->url); 205 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
206 206
207 $client->request('GET', '/view/'.$content->getId()); 207 $client->request('GET', '/view/'.$content->getId());
208 208
@@ -223,7 +223,7 @@ class EntryControllerTest extends WallabagCoreTestCase
223 $content = $client->getContainer() 223 $content = $client->getContainer()
224 ->get('doctrine.orm.entity_manager') 224 ->get('doctrine.orm.entity_manager')
225 ->getRepository('WallabagCoreBundle:Entry') 225 ->getRepository('WallabagCoreBundle:Entry')
226 ->findOneByUrl($this->url); 226 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
227 227
228 // empty content 228 // empty content
229 $content->setContent(''); 229 $content->setContent('');
@@ -237,7 +237,7 @@ class EntryControllerTest extends WallabagCoreTestCase
237 $content = $client->getContainer() 237 $content = $client->getContainer()
238 ->get('doctrine.orm.entity_manager') 238 ->get('doctrine.orm.entity_manager')
239 ->getRepository('WallabagCoreBundle:Entry') 239 ->getRepository('WallabagCoreBundle:Entry')
240 ->findOneByUrl($this->url); 240 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
241 241
242 $this->assertNotEmpty($content->getContent()); 242 $this->assertNotEmpty($content->getContent());
243 } 243 }
@@ -250,7 +250,7 @@ class EntryControllerTest extends WallabagCoreTestCase
250 $content = $client->getContainer() 250 $content = $client->getContainer()
251 ->get('doctrine.orm.entity_manager') 251 ->get('doctrine.orm.entity_manager')
252 ->getRepository('WallabagCoreBundle:Entry') 252 ->getRepository('WallabagCoreBundle:Entry')
253 ->findOneByUrl($this->url); 253 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
254 254
255 $crawler = $client->request('GET', '/edit/'.$content->getId()); 255 $crawler = $client->request('GET', '/edit/'.$content->getId());
256 256
@@ -268,7 +268,7 @@ class EntryControllerTest extends WallabagCoreTestCase
268 $content = $client->getContainer() 268 $content = $client->getContainer()
269 ->get('doctrine.orm.entity_manager') 269 ->get('doctrine.orm.entity_manager')
270 ->getRepository('WallabagCoreBundle:Entry') 270 ->getRepository('WallabagCoreBundle:Entry')
271 ->findOneByUrl($this->url); 271 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
272 272
273 $crawler = $client->request('GET', '/edit/'.$content->getId()); 273 $crawler = $client->request('GET', '/edit/'.$content->getId());
274 274
@@ -298,7 +298,7 @@ class EntryControllerTest extends WallabagCoreTestCase
298 $content = $client->getContainer() 298 $content = $client->getContainer()
299 ->get('doctrine.orm.entity_manager') 299 ->get('doctrine.orm.entity_manager')
300 ->getRepository('WallabagCoreBundle:Entry') 300 ->getRepository('WallabagCoreBundle:Entry')
301 ->findOneByUrl($this->url); 301 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
302 302
303 $client->request('GET', '/archive/'.$content->getId()); 303 $client->request('GET', '/archive/'.$content->getId());
304 304
@@ -320,7 +320,7 @@ class EntryControllerTest extends WallabagCoreTestCase
320 $content = $client->getContainer() 320 $content = $client->getContainer()
321 ->get('doctrine.orm.entity_manager') 321 ->get('doctrine.orm.entity_manager')
322 ->getRepository('WallabagCoreBundle:Entry') 322 ->getRepository('WallabagCoreBundle:Entry')
323 ->findOneByUrl($this->url); 323 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
324 324
325 $client->request('GET', '/star/'.$content->getId()); 325 $client->request('GET', '/star/'.$content->getId());
326 326
@@ -342,7 +342,7 @@ class EntryControllerTest extends WallabagCoreTestCase
342 $content = $client->getContainer() 342 $content = $client->getContainer()
343 ->get('doctrine.orm.entity_manager') 343 ->get('doctrine.orm.entity_manager')
344 ->getRepository('WallabagCoreBundle:Entry') 344 ->getRepository('WallabagCoreBundle:Entry')
345 ->findOneByUrl($this->url); 345 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
346 346
347 $client->request('GET', '/delete/'.$content->getId()); 347 $client->request('GET', '/delete/'.$content->getId());
348 348
diff --git a/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php b/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php
index ce3cabe8..c4905478 100644
--- a/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php
+++ b/src/Wallabag/CoreBundle/Tests/WallabagCoreTestCase.php
@@ -31,4 +31,21 @@ abstract class WallabagCoreTestCase extends WebTestCase
31 31
32 $this->client->submit($form, $data); 32 $this->client->submit($form, $data);
33 } 33 }
34
35 /**
36 * Return the user id of the logged in user.
37 * You should be sure that you called `logInAs` before.
38 *
39 * @return int
40 */
41 public function getLoggedInUserId()
42 {
43 $token = static::$kernel->getContainer()->get('security.token_storage')->getToken();
44
45 if (null !== $token) {
46 return $token->getUser()->getId();
47 }
48
49 throw new \RuntimeException('No logged in User.');
50 }
34} 51}
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index cdcec1e2..72b9047c 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -214,7 +214,7 @@ class PocketImport implements ImportInterface
214 214
215 $existingEntry = $this->em 215 $existingEntry = $this->em
216 ->getRepository('WallabagCoreBundle:Entry') 216 ->getRepository('WallabagCoreBundle:Entry')
217 ->existByUrlAndUserId($url, $this->user->getId()); 217 ->findByUrlAndUserId($url, $this->user->getId());
218 218
219 if (false !== $existingEntry) { 219 if (false !== $existingEntry) {
220 ++$this->skippedEntries; 220 ++$this->skippedEntries;
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
index 393089d6..6f8feaf3 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
@@ -127,7 +127,7 @@ class WallabagV1Import implements ImportInterface
127 foreach ($entries as $importedEntry) { 127 foreach ($entries as $importedEntry) {
128 $existingEntry = $this->em 128 $existingEntry = $this->em
129 ->getRepository('WallabagCoreBundle:Entry') 129 ->getRepository('WallabagCoreBundle:Entry')
130 ->existByUrlAndUserId($importedEntry['url'], $this->user->getId()); 130 ->findByUrlAndUserId($importedEntry['url'], $this->user->getId());
131 131
132 if (false !== $existingEntry) { 132 if (false !== $existingEntry) {
133 ++$this->skippedEntries; 133 ++$this->skippedEntries;
diff --git a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php
index 043b2114..76225fe4 100644
--- a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php
+++ b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php
@@ -248,7 +248,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
248 ->getMock(); 248 ->getMock();
249 249
250 $entryRepo->expects($this->exactly(2)) 250 $entryRepo->expects($this->exactly(2))
251 ->method('existByUrlAndUserId') 251 ->method('findByUrlAndUserId')
252 ->will($this->onConsecutiveCalls(false, true)); 252 ->will($this->onConsecutiveCalls(false, true));
253 253
254 $tag = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Tag') 254 $tag = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Tag')
diff --git a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php
index d5b41777..90483480 100644
--- a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php
+++ b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php
@@ -53,7 +53,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
53 ->getMock(); 53 ->getMock();
54 54
55 $entryRepo->expects($this->exactly(3)) 55 $entryRepo->expects($this->exactly(3))
56 ->method('existByUrlAndUserId') 56 ->method('findByUrlAndUserId')
57 ->will($this->onConsecutiveCalls(false, true, false)); 57 ->will($this->onConsecutiveCalls(false, true, false));
58 58
59 $this->em 59 $this->em