Tests für Upload und Ui, strengere CI-Prüfungen
- tests/UploadTest.php prüft den SVG-Filter (Skripte, Event-Handler, javascript:-Verweise) und Upload::isLocal gegen Pfad-Tricks - tests/UiTest.php prüft Versionsstempel, Media-Pfade und die Branding-Overrides inklusive Abweisung ungültiger Farbwerte - PHPStan analysiert jetzt auch includes/Ui.php und includes/Upload.php - CI vergleicht die Sprachdateien (gleiche Schlüsselmenge) und prüft, dass jeder im Code verwendete Schlüssel existiert Dabei aufgefallen und behoben: Upload.php rief __() direkt auf und wäre außerhalb einer Seite mit geladener I18n mit einem Fatal Error abgebrochen; jetzt gibt es einen Fallback auf die deutsche Meldung. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
36e06ac817
commit
0716311ff6
5 changed files with 220 additions and 10 deletions
35
.github/workflows/ci.yml
vendored
35
.github/workflows/ci.yml
vendored
|
|
@ -29,9 +29,40 @@ jobs:
|
|||
php -l "$f"
|
||||
done
|
||||
|
||||
- name: Validate JSON language/migration assets
|
||||
- name: Validate language files
|
||||
run: |
|
||||
php -r 'foreach (glob("lang/*.php") as $f) { $a = require $f; if (!is_array($a)) { fwrite(STDERR, "Bad lang file: $f\n"); exit(1);} } echo "lang OK\n";'
|
||||
php -r '
|
||||
$de = require "lang/de.php"; $en = require "lang/en.php";
|
||||
if (!is_array($de) || !is_array($en)) { fwrite(STDERR, "Bad lang file\n"); exit(1); }
|
||||
$missingEn = array_diff(array_keys($de), array_keys($en));
|
||||
$missingDe = array_diff(array_keys($en), array_keys($de));
|
||||
if ($missingEn || $missingDe) {
|
||||
fwrite(STDERR, "Fehlend in en: " . implode(", ", $missingEn) . "\n");
|
||||
fwrite(STDERR, "Fehlend in de: " . implode(", ", $missingDe) . "\n");
|
||||
exit(1);
|
||||
}
|
||||
echo "lang OK (" . count($de) . " Schluessel)\n";'
|
||||
|
||||
- name: Check that every used translation key exists
|
||||
run: |
|
||||
php -r '
|
||||
$de = require "lang/de.php";
|
||||
$missing = [];
|
||||
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(".", FilesystemIterator::SKIP_DOTS));
|
||||
foreach ($it as $file) {
|
||||
$path = $file->getPathname();
|
||||
if (substr($path, -4) !== ".php") continue;
|
||||
if (strpos($path, "/vendor/") !== false || strpos($path, "/tools/") !== false) continue;
|
||||
preg_match_all("/__\(\s*\x27([a-z0-9_]+)\x27/", file_get_contents($path), $m);
|
||||
foreach ($m[1] as $key) {
|
||||
if (!isset($de[$key]) && substr($key, -1) !== "_") { $missing[$key] = $path; }
|
||||
}
|
||||
}
|
||||
if ($missing) {
|
||||
foreach ($missing as $key => $path) { fwrite(STDERR, "Unbekannter Schluessel $key in $path\n"); }
|
||||
exit(1);
|
||||
}
|
||||
echo "Alle verwendeten Schluessel vorhanden\n";'
|
||||
|
||||
test:
|
||||
name: Unit Tests & Static Analysis
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue