[FIX] Documenti Istituzionali (#499): le 5 voci standard non comparivano mai (NO_ORG)
Root cause: InstitutionalDocsController::list() usava requireAuth()+getCurrentOrgId(), ma currentOrgId e' popolato solo da requireOrgAccess() → getCurrentOrgId() = null → l'endpoint rispondeva sempre NO_ORG (400) → loadDocs riceveva standards=[] → la card mostrava solo "Aggiungi voce" (screenshot Simon). L'endpoint NON aveva mai funzionato a runtime. - Backend: list() usa resolveOrgId() (risolve X-Organization-Id senza lanciare) e restituisce SEMPRE le 5 voci standard; i documenti salvati solo se un'org e' selezionata. - Frontend (dashboard.js): render condiviso + STD_FALLBACK → le 5 voci si mostrano sempre, anche se l'API fallisce. Buster dashboard.js 20260825. - Backend attivato via reload php-fpm host. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
69f3894c18
commit
396783cd41
@@ -33,16 +33,18 @@ class InstitutionalDocsController extends BaseController
|
||||
public function list(): void
|
||||
{
|
||||
$this->requireAuth();
|
||||
$orgId = $this->getCurrentOrgId();
|
||||
if (!$orgId) { $this->jsonError('Nessuna organizzazione selezionata', 400, 'NO_ORG'); }
|
||||
|
||||
$rows = Database::fetchAll(
|
||||
// BUGFIX (#499): usare requireAuth+getCurrentOrgId dava sempre NO_ORG (currentOrgId
|
||||
// e' popolato solo da requireOrgAccess) → le 5 voci standard non comparivano MAI.
|
||||
// Ora risolviamo l'org dall'header e restituiamo SEMPRE le 5 voci standard;
|
||||
// i documenti salvati si aggiungono solo se un'org e' selezionata.
|
||||
$orgId = $this->resolveOrgId();
|
||||
$rows = $orgId ? Database::fetchAll(
|
||||
"SELECT id, doc_key, title, description, file_url, is_standard, sort_order, updated_at
|
||||
FROM institutional_documents
|
||||
WHERE organization_id = ?
|
||||
ORDER BY is_standard DESC, sort_order ASC, id ASC",
|
||||
[$orgId]
|
||||
);
|
||||
) : [];
|
||||
$this->jsonSuccess(['docs' => $rows, 'standards' => self::STANDARDS]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user