feat(maintenance): optional public 503 and an editable banner - #517
Open
t0ma5 wants to merge 1 commit into
Open
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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