test(schema): pin FOG_SCHEMA to the real step count on this branch too - #1343
Merged
Conversation
Nothing here checks that FOG_SCHEMA and commons/schema.php agree. They do today -- 286 and 286 -- and there has never been a gate holding them there. A fresh install cannot see a disagreement at all: SchemaUpdaterPage::update() slices its step array from self::$mySchema, which is 0 on a new database, so an install runs every step from the beginning whatever the constant says. Only a server that already has a version is affected, and then in the worst way -- `mySchema < FOG_SCHEMA` never stops being true, so DatabaseManager::establish() redirects every request to ?node=schema while the updater, out of steps, answers 204 "Update not required" forever. working-1.6 shipped exactly that in #1338: seven statements appended before commons/schema.php's final `];` joined the previous step instead of becoming steps of their own, so the element count did not move while FOG_SCHEMA was raised. Every CI check was green and a user found it. This branch is where that would cost the most. 1.5.x was meant to be frozen and keeps taking security-driven schema changes, so steps are still appended here, and the installed base upgrading into them is the largest FOG has. Ported from working-1.6 (#1342). Two files, no adaptation needed beyond branch-accurate docblocks -- the collector loads this branch's schema.php unchanged and finds 286 elements at contiguous indexes 0-285. Mutation-verified here, restoring from a copy rather than git checkout: FOG_SCHEMA 286 -> 287 gives "FOG_SCHEMA is 287 but commons/schema.php holds 286 step(s)". Suite: 34 passed, 0 failed. Note this branch carries no equivalent of working-1.6's tests/schema-gate .test.php, which checks the `// N` labels textually, so this is the only thing pinning the invariant here. Co-Authored-By: Claude <noreply@anthropic.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.
Port of #1342 to
dev-branch.The gap
Nothing on this branch checks that
FOG_SCHEMAandcommons/schema.phpagree. They do today — 286 and 286 — and there has never been a gate holding them there.A fresh install cannot see a disagreement at all.
SchemaUpdaterPage::update()slices its step array fromself::$mySchema, which is0on a new database, so an install runs every step from the beginning whatever the constant says. Only a server that already has a version is affected, and then in the worst way:mySchema < FOG_SCHEMAnever stops being true, soDatabaseManager::establish()redirects every request to?node=schemawhile the updater, out of steps, answers 204 "Update not required" forever. There is no way out from the browser — the page that would repair the server is the page that is stuck.working-1.6shipped exactly that in #1338: seven statements appended beforecommons/schema.php's final];joined the previous step instead of becoming steps of their own, so the element count did not move whileFOG_SCHEMAwas raised. Every CI check was green and a user found it.This branch is where that would cost the most. 1.5.x was meant to be frozen and keeps taking security-driven schema changes, so steps are still appended here, and the installed base upgrading into them is the largest FOG has.
What is added
tests/schema-upgrade-replay.test.phpbuilds the real step array and, for every version a server could be sitting on, runs the updater's own expressions over it and requires the stored version to land onFOG_SCHEMA. It also pinscount($this->schema) === FOG_SCHEMAand contiguous keys from zero — the stored version is written as$version + 1from the array key.Needs no database: the upgrade-specific surface is arithmetic, so it runs anywhere
sh tests/run-all.shruns.Porting notes
Two files, no adaptation needed beyond branch-accurate docblocks.
tests/lib/fog-schema-collector.phploads this branch'sschema.phpunchanged and finds 286 elements at contiguous indexes 0–285 — it discovers the file's constants by tokenising and manufactures its classes on demand, so an unrelated schema commit adding either cannot break it.This branch carries no equivalent of
working-1.6'stests/schema-gate.test.php(which checks the// Nlabels textually), so this is the only thing pinning the invariant here.Verification
git checkout --:FOG_SCHEMA286 → 287 givesFAIL: FOG_SCHEMA is 287 but commons/schema.php holds 286 step(s)🤖 Generated with Claude Code
https://claude.ai/code/session_01XqpPXAk7bEm8huH9WkiGk6