aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/debug/report.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/api/debug/report.php b/api/debug/report.php
index a4cf9f1..cefcae6 100644
--- a/api/debug/report.php
+++ b/api/debug/report.php
@@ -61,6 +61,13 @@ foreach (array_slice(array_reverse($existing), 0, 100) as $f) {
$d = json_decode(@file_get_contents($f), true);
if (!is_array($d)) continue;
if (($d['fingerprint'] ?? '') === $fingerprint && strtotime($d['created_at'] ?? '') > $now - 86400) {
+ // Don't discard user content on a duplicate: keep it as an appended note.
+ $d['duplicate_count'] = (int)($d['duplicate_count'] ?? 0) + 1;
+ if ($body !== '' && ($d['body'] ?? '') !== $body) {
+ $d['body'] = trim((string)($d['body'] ?? '') . "\n---\n[duplicate " . gmdate('c') . "] " . $body);
+ $json = json_encode($d, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
+ if ($json !== false) { @file_put_contents($f, $json); @chmod($f, 0664); }
+ }
json_response([
'success' => true,
'id' => $d['id'],
@@ -91,6 +98,12 @@ if ($json === false || file_put_contents($file, $json) === false) {
}
@chmod($file, 0664);
+// Regenerate the public page immediately so the URL we print is never stale.
+$generator = realpath(__DIR__ . '/../../scripts/gen-bug-report.py');
+if ($generator) {
+ @exec('/usr/bin/python3 ' . escapeshellarg($generator) . ' 2>&1', $genOut, $genRc);
+}
+
json_response([
'success' => true,
'id' => $id,