mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
add structured logging for admin/partage form submissions + migration system
- AppLogger: JSON-line logger in storage/logs/form-submissions.log - Logs submissions (admin + partage) with IP, UA, thesis ID, author - Logs errors with context (post keys, share slug) - Migration runner (app/migrations/run.php) handles schema drift - 001_add_objet_column.sql fixes production DB missing 'objet' column - ThesisCreateController::getIdentifier() helper for logging
This commit is contained in:
@@ -500,11 +500,20 @@ function handleShareLinkSubmission(string $slug): void
|
||||
|
||||
require_once APP_ROOT . '/src/Controllers/ThesisCreateController.php';
|
||||
require_once APP_ROOT . '/src/StudentEmail.php';
|
||||
require_once APP_ROOT . '/src/AppLogger.php';
|
||||
|
||||
$logger = new AppLogger();
|
||||
$authorName = $_POST['auteurice'] ?? 'unknown';
|
||||
|
||||
try {
|
||||
$ctrl = ThesisCreateController::make();
|
||||
$thesisId = $ctrl->submit($_POST, $_FILES);
|
||||
|
||||
$identifier = $ctrl->getIdentifier($thesisId);
|
||||
$logger->logSubmission('partage', $thesisId, $identifier, $authorName, [
|
||||
'share_slug' => $slug,
|
||||
]);
|
||||
|
||||
// Send confirmation e-mail (non-blocking; failure doesn't stop redirect)
|
||||
$emailSent = StudentEmail::sendConfirmation(Database::getInstance(), $thesisId, $_POST);
|
||||
|
||||
@@ -521,6 +530,12 @@ function handleShareLinkSubmission(string $slug): void
|
||||
header('Location: /partage/thanks?id=' . urlencode((string)$thesisId));
|
||||
exit();
|
||||
} catch (Exception $e) {
|
||||
$logger->logError('partage', $e->getMessage(), [
|
||||
'share_slug' => $slug,
|
||||
'author' => $authorName,
|
||||
'post_keys' => array_keys($_POST),
|
||||
]);
|
||||
|
||||
error_log('Share link submission error: ' . $e->getMessage());
|
||||
|
||||
$_SESSION['_flash_error'] = $e->getMessage();
|
||||
|
||||
Reference in New Issue
Block a user