require $p)($plan['source'].'/tools/upgrade-runtime.php'); throw_unless(config('database.connections.pgsql.database') === $plan['target']['database'] && config('database.connections.pgsql.port') == 55441 && config('queue.connections.database.queue') === 'localservice-qa' && ! config('portal.notifications_enabled') && config('mail.default') === 'log', RuntimeException::class); $db = Illuminate\Support\Facades\DB::class; throw_unless($db::table('jobs')->count() === 0, RuntimeException::class, 'New clone queue must be empty'); $rows = $db::table('documents')->where('uploaded_by', 17)->where(function ($q) { $q->where('size_bytes', 20971520)->orWhere('media_type', 'image/webp'); })->get(['id','sha256','storage_key','size_bytes','media_type']); throw_unless($rows->count() === 4 && $rows->where('media_type', 'image/webp')->count() === 3, RuntimeException::class, 'Exact synthetic PDF and three WebP required'); $before = $db::table('documents')->count(); $proof = ['at'=>gmdate('c'), 'target'=>$plan['target'], 'queue'=>'localservice-qa', 'documents_before'=>$before, 'resources_before'=>[ 'documents'=>$db::table('opportunity_documents')->count(), 'images'=>$db::table('opportunity_images')->count()], 'documents'=>[], 'active_writes'=>0, 'external_notifications_enabled'=>false]; foreach ($rows as $row) { $path = $plan['source'].'/storage/app/private/'.$row->storage_key; throw_unless(is_file($path), RuntimeException::class, 'Restored synthetic original missing'); $proof['documents'][] = ['id'=>$row->id, 'sha256'=>trim($row->sha256), 'cipher_sha256'=>hash_file('sha256', $path), 'bytes'=>(int)$row->size_bytes, 'media_type'=>$row->media_type]; $db::table('documents')->where('id',$row->id)->update(['status'=>'quarantined', 'malware_scan_status'=>'pending', 'malware_scanned_sha256'=>null, 'malware_failure_reason'=>null]); App\Jobs\ScanDocumentForMalware::dispatch($row->id)->onQueue('localservice-qa'); } throw_unless($db::table('jobs')->where('queue','localservice-qa')->count() === 4, RuntimeException::class); file_put_contents($plan['source'].'/storage/qa-proof/fixture.json', json_encode($proof, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)); echo json_encode(['result'=>'prepared','target'=>$plan['target'],'synthetic_jobs'=>4,'active_writes'=>0], JSON_THROW_ON_ERROR).PHP_EOL;