diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-11-05 16:36:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-05 16:36:34 +0100 |
commit | 47d15818502b11315b484131aaf67a3e3f441c5a (patch) | |
tree | fa37c5e2754a6c8c174411da4c2d80964ad33db1 | |
parent | a4a59e183e565a6933925b3cb30fc8393639ac5a (diff) | |
parent | 330ac859fb13a3a15875f185a611bfaa6c5f5587 (diff) | |
download | Shaarli-47d15818502b11315b484131aaf67a3e3f441c5a.tar.gz Shaarli-47d15818502b11315b484131aaf67a3e3f441c5a.tar.zst Shaarli-47d15818502b11315b484131aaf67a3e3f441c5a.zip |
Merge pull request #1624 from ArthurHoaro/fix/delete-redirect
Fix: redirect to referrer after bookmark deletion
-rw-r--r-- | application/front/controller/admin/ShaareManageController.php | 4 | ||||
-rw-r--r-- | tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/application/front/controller/admin/ShaareManageController.php b/application/front/controller/admin/ShaareManageController.php index 7ceb8d8a..2ed298f5 100644 --- a/application/front/controller/admin/ShaareManageController.php +++ b/application/front/controller/admin/ShaareManageController.php | |||
@@ -66,8 +66,8 @@ class ShaareManageController extends ShaarliAdminController | |||
66 | return $response->write('<script>self.close();</script>'); | 66 | return $response->write('<script>self.close();</script>'); |
67 | } | 67 | } |
68 | 68 | ||
69 | // Don't redirect to where we were previously because the datastore has changed. | 69 | // Don't redirect to permalink after deletion. |
70 | return $this->redirect($response, '/'); | 70 | return $this->redirectFromReferer($request, $response, ['shaare/']); |
71 | } | 71 | } |
72 | 72 | ||
73 | /** | 73 | /** |
diff --git a/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php b/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php index 770a16d7..a276d988 100644 --- a/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php +++ b/tests/front/controller/admin/ShaareManageControllerTest/DeleteBookmarkTest.php | |||
@@ -38,6 +38,8 @@ class DeleteBookmarkTest extends TestCase | |||
38 | { | 38 | { |
39 | $parameters = ['id' => '123']; | 39 | $parameters = ['id' => '123']; |
40 | 40 | ||
41 | $this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/shaare/abcdef'; | ||
42 | |||
41 | $request = $this->createMock(Request::class); | 43 | $request = $this->createMock(Request::class); |
42 | $request | 44 | $request |
43 | ->method('getParam') | 45 | ->method('getParam') |
@@ -90,6 +92,8 @@ class DeleteBookmarkTest extends TestCase | |||
90 | { | 92 | { |
91 | $parameters = ['id' => '123 456 789']; | 93 | $parameters = ['id' => '123 456 789']; |
92 | 94 | ||
95 | $this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/?searchtags=abcdef'; | ||
96 | |||
93 | $request = $this->createMock(Request::class); | 97 | $request = $this->createMock(Request::class); |
94 | $request | 98 | $request |
95 | ->method('getParam') | 99 | ->method('getParam') |
@@ -152,7 +156,7 @@ class DeleteBookmarkTest extends TestCase | |||
152 | $result = $this->controller->deleteBookmark($request, $response); | 156 | $result = $this->controller->deleteBookmark($request, $response); |
153 | 157 | ||
154 | static::assertSame(302, $result->getStatusCode()); | 158 | static::assertSame(302, $result->getStatusCode()); |
155 | static::assertSame(['/subfolder/'], $result->getHeader('location')); | 159 | static::assertSame(['/subfolder/?searchtags=abcdef'], $result->getHeader('location')); |
156 | } | 160 | } |
157 | 161 | ||
158 | /** | 162 | /** |