Force HTTPS from the admin, with a probe before and after

System > HTTPS and cms:https switch the redirect lines in public/.htaccess
only when the site answers over HTTPS, and take them back on a loop. HSTS
is a separate second switch. The redirect block moves before the front
controller rules, where it never reached pages, and .well-known is no
longer denied, so the origin probe works on Apache. The Git updater keeps
switched-on lines like the archive update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kantarciandClaude Opus 5.5 committed 2026-10-12 17:22:56 +02:00
1 parent daad5a1740
commit 8b212d5cc9
15 files changed
+614 -24

No files matched your search

+20 -3
View File
@@ -96,7 +96,7 @@ final class Updater
'git' => $git,
// Der Weg ueber Git steht nur einer Arbeitskopie offen.
'worktree' => $arbeitskopie,
'clean' => null === $status ? null : ('' === $status['output'] && $status['ok']),
'clean' => null === $status ? null : ([] === self::dirty($status['output']) && $status['ok']),
'log' => $this->log(),
];
}
@@ -138,10 +138,10 @@ final class Updater
}
$status = $this->git(['status', '--porcelain']);
$dirty = array_values(array_filter(explode("\n", $status['output'])));
$dirty = self::dirty($status['output']);
$add($checks, 'Keine lokalen Änderungen', [] === $dirty, [] === $dirty
? 'Die Arbeitskopie ist unverändert.'
: sprintf('%d geänderte Datei(en), zum Beispiel %s. Ein Checkout würde sie verwerfen. Erst sichern oder zurücknehmen.', count($dirty), trim(explode("\n", $status['output'])[0])));
: sprintf('%d geänderte Datei(en), zum Beispiel %s. Ein Checkout würde sie verwerfen. Erst sichern oder zurücknehmen.', count($dirty), trim($dirty[0])));
$remote = $this->git(['remote', 'get-url', 'origin']);
$add($checks, 'Herkunft', $remote['ok'], $remote['ok']
@@ -299,8 +299,13 @@ final class Updater
throw new \RuntimeException('Die alte Git-Konfiguration konnte nicht für den Updatewechsel vorbereitet werden.');
}
}
$htaccess = $this->root.'/public/.htaccess';
$htaccessBefore = is_file($htaccess) ? (string) file_get_contents($htaccess) : null;
$checkout = $this->git(['checkout', '--force', $target, '--']);
$this->restoreEnvironment();
if (null !== $htaccessBefore && is_file($htaccess)) {
@file_put_contents($htaccess, HttpsRedirect::keepEnabled((string) file_get_contents($htaccess), $htaccessBefore), LOCK_EX);
}
if (!$step($steps, 'Code wechseln', $checkout['ok'], $checkout['ok'] ? 'Auf '.$target.' gewechselt.' : $checkout['output'])) {
throw new \RuntimeException('checkout');
}
@@ -444,6 +449,18 @@ final class Updater
}
/** Legacy tags tracked .env; preserve the installation even when checking out those tags. */
/**
* Die geänderten Dateien laut `git status --porcelain` - ohne public/.htaccess: Eine dort
* eingeschaltete HTTPS-Umleitung nimmt apply() in die neue Fassung mit (ADR 120), sie ist
* kein Grund, das Update zu verweigern.
*
* @return list<string>
*/
private static function dirty(string $porcelain): array
{
return array_values(array_filter(explode("\n", $porcelain), static fn (string $line): bool => '' !== trim($line) && 1 !== preg_match('#^\s*M{1,2}\s+public/\.htaccess$#', rtrim($line))));
}
private function restoreEnvironment(): void
{
foreach ($this->environmentBefore as $file => $content) {