28 lines
3.0 KiB
PHP
28 lines
3.0 KiB
PHP
<?php
|
|
ini_set('zend.exception_ignore_args','1');putenv('STABILITY_QA_MODE=consumers');
|
|
$b4Root=dirname(__DIR__,2);$b4QA=$b4Root.'/storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742';
|
|
$app=require $b4QA.'/tools/portal-stability-runtime.php';$db=Illuminate\Support\Facades\DB::connection();
|
|
$target=(array)$db->selectOne('SELECT current_database() AS database,inet_server_port() AS port');
|
|
if($target!==['database'=>'stability_consumers_20261011_084534_test','port'=>55441])throw new RuntimeException('QA isolation required');
|
|
$db->beginTransaction();$db->statement('SET TRANSACTION READ ONLY');
|
|
try{
|
|
if(config('portal.notifications_enabled')||config('suitecrm.enabled')||config('investmoz_ai.enabled'))throw new RuntimeException('External integrations must remain off');
|
|
$actor=App\Models\User::findOrFail(22);$access=app(App\Services\PortalProfileAccess::class);
|
|
$candidates=[];foreach([30,31,32,33,34,35,54,56]as$id){$candidate=App\Models\Opportunity::findOrFail($id);$candidates[]=['id'=>$id,'category'=>$candidate->opportunity_category,'state'=>$candidate->workflow_context['working_state']??null,'owner'=>$candidate->owner_user_id,'coeditor_scoped'=>$access->promoterRecordScope($actor,$candidate)];}
|
|
$o=App\Models\Opportunity::findOrFail(30);
|
|
if($o->owner_user_id!==21||$o->opportunity_category!=='investment_project'||$o->workflow_context['working_state']!=='published'||!$access->promoterRecordScope($actor,$o)){
|
|
echo json_encode(['result'=>'fixture_scope_requires_selection','candidates'=>$candidates,'active_writes'=>0]).PHP_EOL;throw new RuntimeException('Select an existing authorized coedition case');
|
|
}
|
|
$v=app(App\Services\OpportunityManagement::class)->values($o)['canonical'];$tables=[];
|
|
foreach(['opportunity_locations','opportunity_documents','opportunity_images','desk_cases','desk_requests','desk_documents','investor_journeys','journey_steps','simulation_form_drafts','tasks','documents','memberships','organizations','portal_role_assignments','portal_superuser_pair']as$name){
|
|
$rows=$db->table($name)->get();$bytes=$rows->map(fn($r)=>json_encode($r,JSON_THROW_ON_ERROR))->all();sort($bytes,SORT_STRING);
|
|
$tables[$name]=['count'=>$rows->count(),'sha256'=>hash('sha256',implode("\n",$bytes))];
|
|
}
|
|
$proof=['at'=>gmdate('c'),'target'=>$target,'SQL_read_only'=>true,'active_writes'=>0,'opportunity_id'=>30,'owner'=>21,'coeditor'=>22,
|
|
'coeditor_same_organization_authorized'=>true,'state'=>'published','baseline_risks'=>$v['risks'],'existing_coeditor_scope'=>$candidates,
|
|
'scope_sha256'=>hash_file('sha256',$b4Root.'/docs/investmoz/v2/auditoria-portal/ambito-B-aceitacao-QA.md'),
|
|
'protected_tables'=>$tables];
|
|
$dest=__DIR__.'/option-B4-preflight.json';if(is_file($dest))throw new RuntimeException('Preserve previous preflight');
|
|
file_put_contents($dest,json_encode($proof,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR));echo json_encode(array_diff_key($proof,['protected_tables'=>true]),JSON_UNESCAPED_UNICODE).PHP_EOL;
|
|
}finally{$db->rollBack();}
|