Email step: append SMTP debug trace to notes (and thus the report)
When debug capture is requested, the trace is now also appended to the step's notes textarea with a clear --- SMTP debug trace ... --- header and timestamp. This means: - The technician can edit/trim the trace before finishing the session. - It flows naturally into the Markdown + HTML report via the existing notes-in-report rendering — no special-casing needed. - Pre-existing notes are preserved (appended to, not overwritten). - Status is preserved. - The collapsible details block on the step card still shows the raw capture for quick reference.
This commit is contained in:
@@ -150,13 +150,26 @@ return new class extends WPH_Step {
|
||||
// mangle the formatting.
|
||||
$session = WPH_Session::current();
|
||||
if ($session && $debug_requested) {
|
||||
$trace = array_slice($trace, 0, 200); // cap to avoid bloating the option
|
||||
$data = $session->data();
|
||||
$data['email_debug'] = [
|
||||
'captured_at' => time(),
|
||||
'transport' => $transport,
|
||||
'trace' => array_slice($trace, 0, 200), // cap to avoid bloating the option
|
||||
'trace' => $trace,
|
||||
];
|
||||
update_option(WPH_OPT_SESSION, $data, false);
|
||||
|
||||
// Append the trace to the step's notes so the technician can edit
|
||||
// it and so it lands in the downloadable report (notes are
|
||||
// already serialised verbatim).
|
||||
$current_state = $session->step_state($this->id());
|
||||
$current_notes = (string) $current_state['notes'];
|
||||
$stamp = date('Y-m-d H:i');
|
||||
$block = "\n\n--- SMTP debug trace (" . $stamp . ", transport: " . $transport . ", to: " . $to . ") ---\n";
|
||||
$block .= $trace ? implode("\n", $trace) : '(no trace lines captured — transport does not emit SMTP traffic)';
|
||||
$block .= "\n--- end trace ---";
|
||||
// Keep whatever status the technician had previously chosen.
|
||||
$session->update_step($this->id(), (string) $current_state['status'], trim($current_notes . $block));
|
||||
}
|
||||
|
||||
$time = date('Y-m-d H:i');
|
||||
|
||||
Reference in New Issue
Block a user