From d873a7f09e6da9c068fae5e9fb8d71f307805453 Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Mon, 11 May 2026 16:22:42 +0200 Subject: [PATCH] fix: add upload-progress.js to partage form (progress bar was missing on public submissions) --- .../pending/033_dedup_format_types.sql | 31 ----------- .../pending/034_dedup_all_lookup_tables.sql | 52 +++++++++++++++++++ app/public/partage/index.php | 1 + app/storage/schema.sql | 24 ++++----- app/templates/admin/acces.php | 26 ++++++++++ 5 files changed, 91 insertions(+), 43 deletions(-) delete mode 100644 app/migrations/pending/033_dedup_format_types.sql create mode 100644 app/migrations/pending/034_dedup_all_lookup_tables.sql diff --git a/app/migrations/pending/033_dedup_format_types.sql b/app/migrations/pending/033_dedup_format_types.sql deleted file mode 100644 index 8997668..0000000 --- a/app/migrations/pending/033_dedup_format_types.sql +++ /dev/null @@ -1,31 +0,0 @@ --- Migration 033: Deduplicate format_types rows (caused by repeated runs of migration 019). --- For each name, keep the row with the lowest id, reassign thesis_formats references. - --- 1. Map each duplicate format_id → canonical format_id -CREATE TEMP TABLE _fmt_map AS -SELECT - dup.id AS old_id, - ( - SELECT MIN(keep.id) - FROM format_types keep - WHERE keep.name = dup.name - ) AS new_id -FROM format_types dup -WHERE dup.id != ( - SELECT MIN(keep.id) - FROM format_types keep - WHERE keep.name = dup.name -); - --- 2. Update affected thesis_formats rows -UPDATE thesis_formats -SET format_id = ( - SELECT new_id FROM _fmt_map WHERE old_id = format_id -) -WHERE format_id IN (SELECT old_id FROM _fmt_map); - --- 3. Delete duplicate rows -DELETE FROM format_types -WHERE id IN (SELECT old_id FROM _fmt_map); - -DROP TABLE _fmt_map; diff --git a/app/migrations/pending/034_dedup_all_lookup_tables.sql b/app/migrations/pending/034_dedup_all_lookup_tables.sql new file mode 100644 index 0000000..429c04b --- /dev/null +++ b/app/migrations/pending/034_dedup_all_lookup_tables.sql @@ -0,0 +1,52 @@ +-- Migration 034: Deduplicate all lookup tables that have no UNIQUE on name/key/slug. +-- Root cause: INSERT OR IGNORE is ineffective without a UNIQUE constraint, +-- and schema.sql was applied repeatedly during broken-migration-runner era. + +-- ── access_types ── +DELETE FROM access_types WHERE id NOT IN (SELECT MIN(id) FROM access_types GROUP BY name); +CREATE UNIQUE INDEX IF NOT EXISTS idx_access_types_name_unique ON access_types(name); + +-- ── ap_programs ── +DELETE FROM ap_programs WHERE id NOT IN (SELECT MIN(id) FROM ap_programs GROUP BY name); +CREATE UNIQUE INDEX IF NOT EXISTS idx_ap_programs_name_unique ON ap_programs(name); + +-- ── finality_types ── +DELETE FROM finality_types WHERE id NOT IN (SELECT MIN(id) FROM finality_types GROUP BY name); +CREATE UNIQUE INDEX IF NOT EXISTS idx_finality_types_name_unique ON finality_types(name); + +-- ── languages ── +DELETE FROM languages WHERE id NOT IN (SELECT MIN(id) FROM languages GROUP BY name); +CREATE UNIQUE INDEX IF NOT EXISTS idx_languages_name_unique ON languages(name); + +-- ── license_types ── +DELETE FROM license_types WHERE id NOT IN (SELECT MIN(id) FROM license_types GROUP BY name); +CREATE UNIQUE INDEX IF NOT EXISTS idx_license_types_name_unique ON license_types(name); + +-- ── orientations ── +DELETE FROM orientations WHERE id NOT IN (SELECT MIN(id) FROM orientations GROUP BY name); +CREATE UNIQUE INDEX IF NOT EXISTS idx_orientations_name_unique ON orientations(name); + +-- ── pages ── +DELETE FROM pages WHERE id NOT IN (SELECT MIN(id) FROM pages GROUP BY slug); +CREATE UNIQUE INDEX IF NOT EXISTS idx_pages_slug_unique ON pages(slug); + +-- ── apropos_contents ── +DELETE FROM apropos_contents WHERE id NOT IN (SELECT MIN(id) FROM apropos_contents GROUP BY key); +CREATE UNIQUE INDEX IF NOT EXISTS idx_apropos_contents_key_unique ON apropos_contents(key); + +-- ── tags ── +DELETE FROM tags WHERE id NOT IN (SELECT MIN(id) FROM tags GROUP BY name); +CREATE UNIQUE INDEX IF NOT EXISTS idx_tags_name_unique ON tags(name); + +-- ── supervisors ── +DELETE FROM supervisors WHERE id NOT IN (SELECT MIN(id) FROM supervisors GROUP BY name); +CREATE UNIQUE INDEX IF NOT EXISTS idx_supervisors_name_unique ON supervisors(name); + +-- ── format_types ── (re-run in case any crept back) +DELETE FROM format_types WHERE id NOT IN (SELECT MIN(id) FROM format_types GROUP BY name); +CREATE UNIQUE INDEX IF NOT EXISTS idx_format_types_name_unique ON format_types(name); + +-- ── Clean up authors with empty email (soft-deleted or dummy rows) +-- These come from CSV import artefacts. Keep only the first per email. +DELETE FROM authors WHERE id NOT IN (SELECT MIN(id) FROM authors GROUP BY email); +CREATE UNIQUE INDEX IF NOT EXISTS idx_authors_email_unique ON authors(email); diff --git a/app/public/partage/index.php b/app/public/partage/index.php index 028964b..c0ef328 100644 --- a/app/public/partage/index.php +++ b/app/public/partage/index.php @@ -403,6 +403,7 @@ function renderShareLinkForm(string $slug, array $link): void + diff --git a/app/storage/schema.sql b/app/storage/schema.sql index 65df00a..afe87c0 100644 --- a/app/storage/schema.sql +++ b/app/storage/schema.sql @@ -6,54 +6,54 @@ CREATE TABLE IF NOT EXISTS orientations ( id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, + name TEXT NOT NULL UNIQUE, created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE IF NOT EXISTS ap_programs ( id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, + name TEXT NOT NULL UNIQUE, code TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE IF NOT EXISTS finality_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, + name TEXT NOT NULL UNIQUE, created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE IF NOT EXISTS languages ( id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, + name TEXT NOT NULL UNIQUE, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, deleted_at TEXT DEFAULT NULL ); CREATE TABLE IF NOT EXISTS format_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, + name TEXT NOT NULL UNIQUE, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, sort_order INTEGER NOT NULL DEFAULT 99 ); CREATE TABLE IF NOT EXISTS tags ( id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, + name TEXT NOT NULL UNIQUE, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, deleted_at TEXT DEFAULT NULL ); CREATE TABLE IF NOT EXISTS access_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, + name TEXT NOT NULL UNIQUE, description TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE IF NOT EXISTS license_types ( id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, + name TEXT NOT NULL UNIQUE, description TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); @@ -69,7 +69,7 @@ CREATE TABLE IF NOT EXISTS authors ( CREATE TABLE IF NOT EXISTS supervisors ( id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, + name TEXT NOT NULL UNIQUE, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ); @@ -186,7 +186,7 @@ CREATE TABLE IF NOT EXISTS system_cache ( CREATE TABLE IF NOT EXISTS pages ( id INTEGER PRIMARY KEY AUTOINCREMENT, - slug TEXT NOT NULL, + slug TEXT NOT NULL UNIQUE, title TEXT NOT NULL, content TEXT, is_published BOOLEAN DEFAULT 1, @@ -196,7 +196,7 @@ CREATE TABLE IF NOT EXISTS pages ( CREATE TABLE IF NOT EXISTS share_links ( id INTEGER PRIMARY KEY AUTOINCREMENT, - slug TEXT NOT NULL, + slug TEXT NOT NULL UNIQUE, objet_restriction TEXT, password_hash TEXT, is_active INTEGER NOT NULL DEFAULT 1, @@ -223,7 +223,7 @@ CREATE TABLE IF NOT EXISTS smtp_settings ( CREATE TABLE IF NOT EXISTS apropos_contents ( id INTEGER PRIMARY KEY AUTOINCREMENT, - key TEXT NOT NULL, + key TEXT NOT NULL UNIQUE, value TEXT, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ); diff --git a/app/templates/admin/acces.php b/app/templates/admin/acces.php index d47b6d9..9e7bda6 100644 --- a/app/templates/admin/acces.php +++ b/app/templates/admin/acces.php @@ -1377,6 +1377,32 @@ +%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision) +\\\\\\\ to: qwkxrvuw f2682d77 "add migration 033 to deduplicate format_types, fix 019 to use INSERT OR IGNORE" (rebased revision) ++ $linkName = $link['name'] ?? ''; +++ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff from: qwkxrvuw f2682d77 "add migration 033 to deduplicate format_types, fix 019 to use INSERT OR IGNORE" (rebased revision) +\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ to: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision) +- $linkName = $link['name'] ?? ''; +- $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff from: somsyvxz 14a3cd10 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebase destination) +\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ to: zymtprsp 3c3a5053 (rebased revision) + $linkName = $link['name'] ?? ''; + $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; + $linkLockedYear = $link['locked_year'] ?? null; ++%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision) ++\\\\\\\ to: zymtprsp 94ce00e4 (rebased revision) +++ $linkName = $link['name'] ?? ''; +++ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff from: zymtprsp 94ce00e4 (rebased revision) +\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ to: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision) +- $linkName = $link['name'] ?? ''; +- $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff from: somsyvxz 14a3cd10 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebase destination) +\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ to: vpmpppym 7ef20766 "add upload-progress.js to partage form (progress bar was missing on public submissions)" (rebased revision) + $linkName = $link['name'] ?? ''; + $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; + $linkLockedYear = $link['locked_year'] ?? null; ++%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision) ++\\\\\\\ to: vpmpppym dde7c80e "add upload-progress.js to partage form (progress bar was missing on public submissions)" (rebased revision) +++ $linkName = $link['name'] ?? ''; ++ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; ?>