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:
Pontoporeia
2026-03-28 11:35:23 +01:00
parent b0632b4772
commit 2e277b104e
5 changed files with 42 additions and 143 deletions

View File

@@ -71,17 +71,6 @@ try {
throw new Exception("getUsedTags did not return expected structure: " . json_encode($tags[0] ?? []));
}
// Test 7: backwards-compat alias findOrCreateKeyword
echo "Test 7: findOrCreateKeyword alias\n";
$testTag2 = '__kw_alias_' . bin2hex(random_bytes(4));
$kwId = $db->findOrCreateKeyword($testTag2);
if ($kwId > 0) {
echo "✓ PASS: findOrCreateKeyword alias works, id=$kwId\n\n";
$db->deleteTag($kwId);
} else {
throw new Exception("findOrCreateKeyword alias failed");
}
echo "✅ All database tests passed!\n";
return true;