Skip to content

Commit 32ad655

Browse files
committed
avoid duplicated patch comments with a redirect
1 parent eee1a62 commit 32ad655

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

index.php

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
1616
use Symfony\Component\Form\Forms;
17+
use Symfony\Component\HttpFoundation\RedirectResponse;
1718

1819
$formFactory = Forms::createFormFactoryBuilder()
1920
->addExtension(new HttpFoundationExtension())
@@ -174,6 +175,12 @@ function terminate($error_message = null, $template = 'main.html.twig',
174175
exit();
175176
}
176177

178+
function terminate_redirect() {
179+
db_flush();
180+
(new RedirectResponse($_SERVER['REQUEST_URI']))->send();
181+
exit();
182+
}
183+
177184
function get_webpack_deps() {
178185
$json = json_decode(file_get_contents('assets/public/entrypoints.json'));
179186
$html = '';

pages/editpatch.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// Distributed under the MIT license that can be found in the LICENSE file.
44

55
use Symfony\Component\Form\Extension\Core\Type\FormType;
6-
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
76
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
87
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
98

@@ -31,9 +30,6 @@
3130
$prev_status = $patch->getStatus();
3231

3332
$comments_form = $formFactory->createNamedBuilder('comments', FormType::class)
34-
->add('id', HiddenType::class, [
35-
'data' => $patch->id,
36-
])
3733
->add('text', TextareaType::class, [
3834
'attr' => [
3935
'rows' => 7,
@@ -77,6 +73,7 @@
7773
$new_comment = "Status changed: $prev_status$new_status\n\n$new_comment";
7874
}
7975
$patch->comments->add(new PatchComment($patch, $new_comment, $user));
76+
terminate_redirect();
8077
}
8178

8279
$old_video_url = $patch->video_url;

0 commit comments

Comments
 (0)