Skip to content

test(schema): pin FOG_SCHEMA to the real step count on this branch too - #1343

Merged
mastacontrola merged 1 commit into
dev-branchfrom
test-upgrade-replay-gate-dev
Aug 24, 2026
Merged

test(schema): pin FOG_SCHEMA to the real step count on this branch too#1343
mastacontrola merged 1 commit into
dev-branchfrom
test-upgrade-replay-gate-dev

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

Port of #1342 to dev-branch.

The gap

Nothing on this branch 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. There is no way out from the browser — the page that would repair the server is the page that is stuck.

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.

What is added

tests/schema-upgrade-replay.test.php builds 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 on FOG_SCHEMA. It also pins count($this->schema) === FOG_SCHEMA and contiguous keys from zero — the stored version is written as $version + 1 from the array key.

Needs no database: the upgrade-specific surface is arithmetic, so it runs anywhere sh tests/run-all.sh runs.

Porting notes

Two files, no adaptation needed beyond branch-accurate docblocks. tests/lib/fog-schema-collector.php loads this branch's schema.php unchanged 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's tests/schema-gate.test.php (which checks the // N labels textually), so this is the only thing pinning the invariant here.

Verification

  • Suite on this branch: 34 passed, 0 failed
  • Mutation-verified here, restoring from a copy rather than git checkout --: FOG_SCHEMA 286 → 287 gives FAIL: FOG_SCHEMA is 287 but commons/schema.php holds 286 step(s)

🤖 Generated with Claude Code

https://claude.ai/code/session_01XqpPXAk7bEm8huH9WkiGk6

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>
@mastacontrola
mastacontrola merged commit 4a50b53 into dev-branch Aug 24, 2026
7 checks passed
@mastacontrola
mastacontrola deleted the test-upgrade-replay-gate-dev branch August 24, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant