mirror of
https://github.com/dyzulk/trustlab-api.git
synced 2026-01-26 05:15:35 +07:00
chore: remove logs and debug scripts
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\TicketAttachment;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
$app = require_once __DIR__ . '/bootstrap/app.php';
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
$kernel->bootstrap();
|
||||
|
||||
// ID from your error message
|
||||
$id = '019b8920-93ee-7052-9282-b6f6b320b741';
|
||||
|
||||
echo "--- Attachment Debugger ---\n";
|
||||
echo "Target ID: $id\n\n";
|
||||
|
||||
// 1. Check Database
|
||||
echo "[1] Checking Database Record...\n";
|
||||
$attachment = TicketAttachment::find($id);
|
||||
|
||||
if (!$attachment) {
|
||||
echo "ERROR: Record not found in database.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "Found Record!\n";
|
||||
echo "- ID: " . $attachment->id . "\n";
|
||||
echo "- File Name: " . $attachment->file_name . "\n";
|
||||
echo "- Stored Path: " . $attachment->file_path . "\n";
|
||||
echo "- Created At: " . $attachment->created_at . "\n";
|
||||
|
||||
// 2. Check Disk
|
||||
$path = $attachment->file_path;
|
||||
$disk = 'r2-private';
|
||||
|
||||
echo "\n[2] Checking R2 Private Storage...\n";
|
||||
echo "Disk: $disk\n";
|
||||
echo "Path: $path\n";
|
||||
|
||||
try {
|
||||
if (filter_var($path, FILTER_VALIDATE_URL)) {
|
||||
echo "WARNING: Path is a full URL ($path). This logic is legacy/public.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$exists = Storage::disk($disk)->exists($path);
|
||||
|
||||
if ($exists) {
|
||||
echo "STATUS: FILE EXISTS ✅\n";
|
||||
|
||||
// Try reading first 100 bytes
|
||||
$content = Storage::disk($disk)->get($path);
|
||||
echo "Read Test: Success (" . strlen($content) . " bytes read)\n";
|
||||
} else {
|
||||
echo "STATUS: FILE NOT FOUND ❌\n";
|
||||
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";
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
$app = require_once __DIR__ . '/bootstrap/app.php';
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
$kernel->bootstrap();
|
||||
|
||||
echo "--- R2 Connectivity Debug ---\n";
|
||||
|
||||
// 1. Check Config
|
||||
echo "\n[1] Checking Configuration:\n";
|
||||
$publicBucket = Config::get('filesystems.disks.r2-public.bucket');
|
||||
$privateBucket = Config::get('filesystems.disks.r2-private.bucket');
|
||||
$privateKey = Config::get('filesystems.disks.r2-private.key');
|
||||
|
||||
echo "R2 Public Bucket: " . ($publicBucket ? "SET ($publicBucket)" : "MISSING") . "\n";
|
||||
echo "R2 Private Bucket: " . ($privateBucket ? "SET ($privateBucket)" : "MISSING") . "\n";
|
||||
echo "R2 Key Present: " . ($privateKey ? "YES" : "NO") . "\n";
|
||||
|
||||
if (!$privateBucket) {
|
||||
echo "ERROR: R2_PRIVATE_BUCKET is not set in config. Did you run 'php artisan config:clear'?\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// 2. Test Private Disk
|
||||
echo "\n[2] Testing 'r2-private' Disk Write/Read:\n";
|
||||
try {
|
||||
$testFile = 'debug-connectivity-' . time() . '.txt';
|
||||
echo "Attempting to write $testFile ... ";
|
||||
|
||||
$result = Storage::disk('r2-private')->put($testFile, 'Connectivity Test ' . now());
|
||||
|
||||
if ($result) {
|
||||
echo "SUCCESS\n";
|
||||
echo "Attempting to delete ... ";
|
||||
Storage::disk('r2-private')->delete($testFile);
|
||||
echo "SUCCESS\n";
|
||||
} else {
|
||||
echo "FAILED (Write returned false)\n";
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
echo "EXCEPTION: " . $e->getMessage() . "\n";
|
||||
echo "Trace: " . $e->getTraceAsString() . "\n";
|
||||
}
|
||||
Reference in New Issue
Block a user