]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Fix: redirect to referrer after bookmark deletion 1624/head
authorArthurHoaro <arthur@hoa.ro>
Thu, 5 Nov 2020 15:14:22 +0000 (16:14 +0100)
committerArthurHoaro <arthur@hoa.ro>
Thu, 5 Nov 2020 15:14:27 +0000 (16:14 +0100)
Except if the referer points to a permalink (which has been deleted).

Fixes #1622

application/front/controller/admin/ShaareManageController.php
tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php

index 7ceb8d8a3584e046c94c51c6999e39a5974bf3dc..2ed298f5e4cefb163371bf372df7eeb5c7241c7e 100644 (file)
@@ -66,8 +66,8 @@ class ShaareManageController extends ShaarliAdminController
             return $response->write('<script>self.close();</script>');
         }
 
-        // Don't redirect to where we were previously because the datastore has changed.
-        return $this->redirect($response, '/');
+        // Don't redirect to permalink after deletion.
+        return $this->redirectFromReferer($request, $response, ['shaare/']);
     }
 
     /**
index 770a16d7c543b70c1265ec90d85b2348e969661e..a276d988f0d1993c7278cbbf30debdab02055e17 100644 (file)
@@ -38,6 +38,8 @@ class DeleteBookmarkTest extends TestCase
     {
         $parameters = ['id' => '123'];
 
+        $this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/shaare/abcdef';
+
         $request = $this->createMock(Request::class);
         $request
             ->method('getParam')
@@ -90,6 +92,8 @@ class DeleteBookmarkTest extends TestCase
     {
         $parameters = ['id' => '123 456 789'];
 
+        $this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/?searchtags=abcdef';
+
         $request = $this->createMock(Request::class);
         $request
             ->method('getParam')
@@ -152,7 +156,7 @@ class DeleteBookmarkTest extends TestCase
         $result = $this->controller->deleteBookmark($request, $response);
 
         static::assertSame(302, $result->getStatusCode());
-        static::assertSame(['/subfolder/'], $result->getHeader('location'));
+        static::assertSame(['/subfolder/?searchtags=abcdef'], $result->getHeader('location'));
     }
 
     /**