From d6b7a51c7f8603d7ed60f0ce2e5a6ebd56148534 Mon Sep 17 00:00:00 2001 From: dyzulk <66510723+dyzulk@users.noreply.github.com> Date: Sun, 4 Jan 2026 22:48:18 +0700 Subject: [PATCH] chore: extend debug script for relationship check --- debug-attachment.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/debug-attachment.php b/debug-attachment.php index 92a8f3c..c0a9953 100644 --- a/debug-attachment.php +++ b/debug-attachment.php @@ -56,6 +56,24 @@ try { echo "Diagnosis: Upload failed or path mismatch.\n"; } + // 3. Check Relationships (Simulate Controller Auth) + echo "\n[3] Checking Relationships (Auth Logic)...\n"; + $reply = $attachment->reply; + if (!$reply) { + echo "FATAL: Attachment has NO linked Reply (ticket_reply_id: " . ($attachment->ticket_reply_id ?? 'NULL') . ").\n"; + echo "Controller Logic `$attachment->reply->ticket` will CRASH here.\n"; + } else { + echo "Reply Found: ID " . $reply->id . "\n"; + $ticket = $reply->ticket; + if (!$ticket) { + echo "FATAL: Reply has NO linked Ticket.\n"; + echo "Controller Logic `$ticket->user_id` will CRASH here.\n"; + } else { + echo "Ticket Found: ID " . $ticket->id . " (Owner: " . $ticket->user_id . ")\n"; + echo "Auth Logic seems SAFE.\n"; + } + } + } catch (\Exception $e) { echo "EXCEPTION: " . $e->getMessage() . "\n"; }