feat(maintenance): optional public 503 and an editable banner - #517
Conversation
Keep .maintenance as the on/off switch and default lockout on so existing sites and the upgrade path that touches the file still 503 visitors. Unchecking lockout leaves the site up with a plain-text banner. CLI cron is not 503'd. Only fclose the flag file when fopen succeeded. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Holding this one, I'll come back to it. One thing to look at meanwhile: |
Themes run the header hook inside <head>, so showing the bar to every visitor would dump a div and inline CSS above the fold. footer is the required body hook; a short script then prepends the bar as body's first child. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Moved Themes run
A new required |
# Conflicts: # .github/workflows/test.yml
Why
.maintenanceis still the only on/off switch. Today that file always 503s the public site. That is the right default for an upgrade (core alreadytouches the file) and for anyone who already relies on lockout. This PR adds a second, optional layer: keep the site up and show a banner whose text the admin edits.Nothing site-specific, no extra routes, no HTML in the banner.
Logic
.maintenance. That is unchanged.maintenance_lockoutreads as on. Existing installs and the upgrade path that writes the file still 503 visitors. Only an explicit0(unchecked checkbox, saved) is the soft mode.__OSC_MAINTENANCE__is defined so the header bar renders. The bar shows the saved message (escaped); if the message is blank, the previous default copy (with the site title) is used.maintenance.phpstill wins if the theme ships one; otherwiseosc_die()uses the same (escaped) message. Admins skip the 503 and see the bar, with copy that says only signed-in admins can see the site.osc_is_admin_user_logged_in()still bypasses lockout.php index.php -p cronis not an admin session, so today it would hit the 503 path during lockout and cron would not run. CLI is exempted.oc-cli.phpnever went throughindex.phpand is unchanged.strip_tags, max 500 characters. HTML is not stored. Output goes throughosc_esc_html(andnl2br) on the banner and on the 503 page.fopenof.maintenanceonlyfcloses a real handle. PHP 8 type-errors iffopenfailed and we still closedfalse.Prefs: section
osclass,maintenance_lockoutBOOLEAN,maintenance_messageSTRING. The 503/banner decision is a pair of pure helpers so the default-on lockout and the sanitizer can be pinned without a database (tests/maintenance-mode.php).How to test
<script>in the message must not run.php index.php -p cron -t hourlywhile.maintenanceexists and lockout is on: cron still runs (no 503).Made with Cursor