mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
refactor(Database): remove dead CRUD helpers and alias proliferation
Remove 5 unused ID-lookup helpers (getOrientationId, getAPProgramId,
getFinalityId, getLanguageId, getFormatId) — forms have always passed
FK ids directly from <select> elements; these methods were never called
outside import.php, which now uses inline PDO queries instead.
Collapse 13 alias methods down to the single canonical name for each:
getAllOrientations, getAllAPPrograms, getAllFinalityTypes,
getAllFormatTypes, getAllLanguages, getAllLicenseTypes,
getUsedTags, findOrCreateTag
The short-name variants (getOrientations, getApPrograms, etc.) and
compat aliases (getUsedKeywords, findOrCreateKeyword, getAllLicenseTypes
delegating to getLicenseTypes) are deleted. All call-sites updated:
- public/search.php: getOrientations→getAllOrientations, etc.
- public/admin/import.php: findOrCreateKeyword→findOrCreateTag,
thesis_keywords→thesis_tags, keyword_id→tag_id (fixes stale table
reference from pre-migration-001 that bypassed the M2M rename)
- tests/Unit/DatabaseTest.php: remove alias smoke-test (test 7)
Database.php: 948 → 848 lines (-100).
This commit is contained in:
16
TODO.md
16
TODO.md
@@ -378,16 +378,14 @@ Goal: rename the tables and column to the canonical M2M pattern (`tags`, `thesis
|
||||
|
||||
### B — PHP / Database.php
|
||||
|
||||
- [ ] **Dead CRUD helpers** — `getOrientationId()`, `getAPProgramId()`, `getFinalityId()`,
|
||||
`getLanguageId()`, `getFormatId()` are defined in `Database.php` but **never called** anywhere
|
||||
(forms now pass IDs directly from selects). Remove them to reduce surface area.
|
||||
- [x] **Dead CRUD helpers** — `getOrientationId()`, `getAPProgramId()`, `getFinalityId()`,
|
||||
`getLanguageId()`, `getFormatId()` removed from `Database.php`; `import.php` updated to
|
||||
use inline PDO queries in their place.
|
||||
|
||||
- [ ] **Alias proliferation** — `getOrientations()`/`getAllOrientations()`, `getApPrograms()`/`getAllAPPrograms()`,
|
||||
`getFinalityTypes()`/`getAllFinalityTypes()`, `getLanguages()`/`getAllLanguages()`,
|
||||
`getFormatTypes()`/`getAllFormatTypes()`, `getLicenseTypes()`/`getAllLicenseTypes()`,
|
||||
`findOrCreateKeyword()`, `getUsedKeywords()` — **13 alias methods** pointing at 6 real ones.
|
||||
Pick the canonical name for each pair, update all call-sites (there are few), and delete aliases.
|
||||
Reduces Database.php from ~945 lines significantly.
|
||||
- [x] **Alias proliferation** — collapsed 13 alias methods: canonical names are the `getAllXxx`
|
||||
variants (`getAllOrientations`, `getAllAPPrograms`, `getAllFinalityTypes`, `getAllFormatTypes`,
|
||||
`getAllLanguages`, `getAllLicenseTypes`) plus `getUsedTags` and `findOrCreateTag`; all
|
||||
call-sites updated (`search.php`, `import.php`); Database.php reduced from 948 → 848 lines.
|
||||
|
||||
- [ ] **`getPDO()` / `getConnection()` leaking to callers** — `edit.php`, `formulaire.php`,
|
||||
`thanks.php`, `import.php`, `tfe.php`, `index.php`, `media.php`, `system.php` all call
|
||||
|
||||
Reference in New Issue
Block a user