Rebuild DEEG as a fifth installation, add stepped forms and a plugin system, and clear the review backlog

Forms gained steps, conditions, image choices, number fields with units and a
summary step; the DEEG price finder uses all of it. Plugins are manifest plus
Twig: blocks, settings, containers, routes, presets and theme packs, switched
per installation. The review backlog is done: archive pages render through the
normal page pipeline, forms and post lists work inside areas and sections,
repeated sections get their own ids, breakpoints and colours come from the
palette, backup and update work on MySQL and lock each other out.

The task worker no longer shortens a process that has no time limit:
set_time_limit() sets the limit instead of extending it, which turned an
unlimited CLI run into eighty seconds and killed the full test suite far away
from the scheduler.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
kantarciandClaude Opus 5 committed 2026-09-16 07:32:35 +02:00
1 parent 66ff68abf8
commit c8a8fa7460
74 files changed
+5352 -243

No files matched your search

+96 -11
View File
@@ -172,14 +172,22 @@ final class Backup
$file = $this->databaseFile();
if (null === $file) {
$step($steps, 'Datenbank zurückschreiben', false, 'Diese Installation nutzt keine Dateidatenbank. Für MySQL fehlt das Einspielen noch (siehe docs/UPDATE.md).');
// MySQL: der Dump wird mit dem Client eingespielt - derselbe Weg, den man von Hand
// gehen wuerde, nur ohne Tippfehler in der Verbindung.
try {
$this->loadMysql($path.'/'.(string) ($manifest['datenbank']['datei'] ?? 'datenbank.sql'));
$step($steps, 'Datenbank zurückschreiben', true, 'Der Dump wurde mit dem MySQL-Client eingespielt.');
} catch (InvalidPage $fehler) {
$step($steps, 'Datenbank zurückschreiben', false, $fehler->getMessage());
return ['steps' => $steps, 'ok' => false];
}
$this->db->close();
$copied = @copy($path.'/'.basename($file), $file);
if (!$step($steps, 'Datenbank zurückschreiben', $copied, $copied ? basename($file).' ersetzt.' : 'Die Datei ließ sich nicht ersetzen.')) {
return ['steps' => $steps, 'ok' => false];
return ['steps' => $steps, 'ok' => false];
}
} else {
$this->db->close();
$copied = @copy($path.'/'.basename($file), $file);
if (!$step($steps, 'Datenbank zurückschreiben', $copied, $copied ? basename($file).' ersetzt.' : 'Die Datei ließ sich nicht ersetzen.')) {
return ['steps' => $steps, 'ok' => false];
}
}
// Media are added, never deleted: files uploaded after the backup would otherwise be lost
@@ -216,10 +224,7 @@ final class Backup
{
$file = $this->databaseFile();
if (null === $file) {
if (!$this->runner->has('mysqldump', $this->root)) {
throw new InvalidPage('Diese Installation nutzt keine Dateidatenbank, und mysqldump ist nicht aufrufbar. Ohne eines von beiden gibt es keine Sicherung.');
}
throw new InvalidPage('Sicherung über mysqldump ist noch nicht umgesetzt (Arbeitspaket J).');
return $this->dumpMysql($directory);
}
$target = $directory.'/'.basename($file);
// VACUUM INTO statt copy(): Eine Kopie, die waehrend eines Schreibvorgangs entsteht, kann
@@ -366,6 +371,86 @@ final class Backup
@rmdir($path);
}
/**
* Die Verbindungsdaten einer MySQL/MariaDB-Adresse, oder null bei einer Dateidatenbank.
*
* @return array{host: string, port: string, user: string, password: string, name: string}|null
*/
private function mysqlConnection(): ?array
{
if (1 !== preg_match('#^(mysql|mariadb)://#', $this->databaseUrl)) {
return null;
}
$teile = parse_url($this->databaseUrl);
if (!is_array($teile) || '' === trim((string) ($teile['path'] ?? ''), '/')) {
return null;
}
return [
'host' => (string) ($teile['host'] ?? '127.0.0.1'), 'port' => (string) ($teile['port'] ?? 3306),
'user' => rawurldecode((string) ($teile['user'] ?? '')), 'password' => rawurldecode((string) ($teile['pass'] ?? '')),
'name' => trim((string) $teile['path'], '/'),
];
}
/** @return list<string> die Verbindungsargumente fuer mysqldump und mysql */
private function mysqlArguments(array $verbindung): array
{
$args = ['--host='.$verbindung['host'], '--port='.$verbindung['port'], '--user='.$verbindung['user']];
if ('' !== $verbindung['password']) {
// Als Argument, nicht als Umgebungsvariable: der Befehlslaeufer startet mit einer
// festen Umgebung. Das Argument ist fuer andere Nutzer des Servers kurz sichtbar -
// wie bei jedem mysqldump-Aufruf von Hand.
$args[] = '--password='.$verbindung['password'];
}
return $args;
}
/** @return array{datei: string, bytes: int, sha256: string} */
private function dumpMysql(string $directory): array
{
$verbindung = $this->mysqlConnection();
if (null === $verbindung) {
throw new InvalidPage('Die Datenbankadresse ist weder eine SQLite-Datei noch eine MySQL-Verbindung.');
}
$dump = $this->runner->resolve('mysqldump', $this->root);
if (null === $dump) {
throw new InvalidPage('Diese Installation nutzt MySQL, und mysqldump ist nicht aufrufbar. Ohne den Client gibt es keine Sicherung - beim Hoster nach dem Pfad fragen.');
}
$target = $directory.'/datenbank.sql';
// --single-transaction: ein konsistenter Stand ohne Sperre der Tabellen; --result-file:
// direkt in die Datei, nicht durch den Speicher dieses Prozesses.
$ergebnis = $this->runner->run([...$dump, ...$this->mysqlArguments($verbindung), '--single-transaction', '--quick', '--skip-lock-tables', '--routines', '--result-file='.$target, $verbindung['name']], $this->root, 900);
if (!$ergebnis['ok'] || !is_readable($target) || 0 === (int) filesize($target)) {
@unlink($target);
throw new InvalidPage('mysqldump ist gescheitert: '.trim($ergebnis['output']));
}
return ['datei' => 'datenbank.sql', 'bytes' => (int) filesize($target), 'sha256' => (string) hash_file('sha256', $target)];
}
/** Spielt einen Dump mit dem MySQL-Client ein. @throws InvalidPage */
private function loadMysql(string $dump): void
{
$verbindung = $this->mysqlConnection();
if (null === $verbindung) {
throw new InvalidPage('Die Datenbankadresse ist keine MySQL-Verbindung.');
}
if (!is_readable($dump)) {
throw new InvalidPage('Der Dump fehlt in der Sicherung: '.basename($dump));
}
$client = $this->runner->resolve('mysql', $this->root);
if (null === $client) {
throw new InvalidPage('Der MySQL-Client (mysql) ist nicht aufrufbar; der Dump liegt unter '.$dump.' und lässt sich von Hand einspielen.');
}
$this->db->close();
$ergebnis = $this->runner->run([...$client, ...$this->mysqlArguments($verbindung), '--database='.$verbindung['name'], '--execute=source '.str_replace('\\', '/', $dump)], $this->root, 900);
if (!$ergebnis['ok']) {
throw new InvalidPage('Der MySQL-Client hat den Dump nicht eingespielt: '.trim($ergebnis['output']));
}
}
private function databaseFile(): ?string
{
if (!str_starts_with($this->databaseUrl, 'sqlite:')) {