Skip to content

Add upgrade group management and parallel wiki upgrade support - #19

Merged
Zippybonzo merged 4 commits into
mainfrom
claude/tender-franklin-o5w8zt
Sep 22, 2026
Merged

Zippybonzo merged 4 commits into
mainfrom
claude/tender-franklin-o5w8zt

Conversation

@Zippybonzo

@Zippybonzo Zippybonzo commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR adds comprehensive support for managing staged wiki upgrades through upgrade groups and parallel processing. It introduces a new ManageUpgradeGroups maintenance script for managing rollout groups, significantly refactors UpgradeWiki to support upgrading multiple wikis in parallel, and adds a new UpgradeGroups utility class for reading/writing group database lists.

Key Changes

  • New UpgradeGroups class (includes/UpgradeGroups.php):

    • Manages upgrade group database lists (group1, group2, ...) stored in cw_cache
    • Provides methods to read/write groups, detect duplicates, and manage assignments
    • Supports configurable cache directory and group name prefix
  • New ManageUpgradeGroups maintenance script (maintenance/ManageUpgradeGroups.php):

    • Comprehensive CLI tool for managing upgrade groups
    • Operations: list groups, add/remove wikis, create groups by percentage/count/all, check for duplicates, delete groups
    • Supports filtering by wiki state (active, closed, inactive, deleted, public, private)
    • Features: random selection with seed, dry-run mode, file input, move wikis between groups
    • Validates wiki names against $wgLocalDatabases by default
  • Refactored UpgradeWiki maintenance script (maintenance/UpgradeWiki.php):

    • Changed from LoggedUpdateMaintenance to Maintenance for more control
    • Now supports upgrading multiple wikis via arguments, --group, or --file
    • Added --parallel option to run multiple wiki upgrades concurrently (default: 1)
    • Added --change-version and --change-version-after options for batch version updates
    • Implements child process management with output prefixing by wiki name
    • Added --force to re-run upgrades on already-upgraded wikis
    • Added --continue-on-error to keep upgrading remaining wikis after failures
    • Added --dry-run to preview what would be upgraded
    • Separates wiki selection (--wiki only affects script's boot wiki) from upgrade targets
    • Batches version changes to regenerate database lists once per batch instead of per wiki
  • Updated ChangeMediaWikiVersion (maintenance/ChangeMediaWikiVersion.php):

    • Enhanced to support batch version changes with single database list regeneration
    • Improved version resolution logic
  • Updated README.md:

    • Added comprehensive documentation for upgrade workflow
    • Included examples of single-wiki and staged rollout upgrades
    • Documented rollout group management

Notable Implementation Details

  • Child processes are managed with non-blocking pipes to stream output in real-time with wiki name prefixes
  • Upgrade groups are stored as PHP files in cw_cache with StaticArrayWriter for consistency with CreateWiki's format
  • Duplicate detection runs on every execution and reports conflicts
  • Version changes are batched to minimize database list regeneration overhead
  • The script validates wiki names against $wgLocalDatabases unless --skip-validation is passed
  • Supports both percentage-based and count-based group population with optional randomization

https://claude.ai/code/session_01MXN8RgK2iUq9jh74muDMWk

Summary by CodeRabbit

  • New Features

    • Added batch wiki upgrades with grouping, parallel processing, dry-run, version changes, force, and continue-on-error options.
    • Added upgrade-group management, including adding, moving, removing, selecting, validating, and deleting wiki groups.
    • Added duplicate detection and safeguards to prevent a wiki from appearing in multiple groups.
  • Bug Fixes

    • Skips wikis that are already upgraded or already on the requested version.
    • Regenerates database lists only when changes occur.
  • Documentation

    • Documented the new upgrade and upgrade-group maintenance commands and available options.

UpgradeWiki previously upgraded whichever wiki --wiki selected, which meant
the script had to run under every wiki in turn and --change-version was only
safe on a single wiki.

The wikis to upgrade are now positional arguments, or come from --group or
--file, and --wiki only decides which wiki the script itself runs under. A
maintenance class instantiated in-process always talks to the database of the
wiki the process was booted for, so steps for any other wiki are now run as
separate maintenance/run.php --wiki=<target> processes. ChangeMediaWikiVersion
is pinned to the target wiki with --regex, so --change-version is safe for
multi-wiki runs.

Because the run is no longer one wiki per process, LoggedUpdateMaintenance no
longer fits: each wiki's upgrade-wiki-<mwversion> row is written to its own
updatelog, with --force to re-run and --continue-on-error to carry on past a
failed wiki.

Adds ManageUpgradeGroups, which manages the group1, group2, ... database lists
in cw_cache that UpgradeWiki --group deploys to: listing, adding, moving and
removing wikis, creating or topping up a group to cover a given percentage of
the fleet, and auditing the lists. A wiki is never placed in two groups, and
every run reports duplicates (--check --fix drops them).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MXN8RgK2iUq9jh74muDMWk
Version changes for a whole batch now happen in one ChangeMediaWikiVersion
pass with a single database list regeneration, instead of one full
regeneration per wiki. That regeneration rewrites this server's copy and bumps
CreateWiki's global timestamp, so every other server regenerates once too.
--change-version flips every target first; --change-version-after flips only
the wikis that upgraded cleanly, once their schema changes are in.

Each target wiki is now upgraded in its own run.php --wiki=<target> process,
with that wiki's steps run in-process inside it, so MediaWiki boots once per
wiki rather than once per step. --parallel runs several at a time, with output
prefixed by wiki name. Without --continue-on-error the first failure stops new
wikis from starting and lets the running ones finish.

ChangeMediaWikiVersion reads the current version off the cw_wikis row it has
already loaded rather than re-including databases.php for every wiki, skips
wikis already on the target version, and skips the regeneration when nothing
changed.

ManageUpgradeGroups can select wikis by state (--state, --exclude-state) using
CreateWiki's active/closed/inactive/deleted/public/private lists, and fill a
group with --add-all, --count or --percent of the selected wikis. Group names
are now restricted to group<number> so a group can never overwrite a CreateWiki
list or a per-wiki cache file in cw_cache. Also defines formatPercent(), which
the previous commit called without defining, breaking --list, --check and
--percent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MXN8RgK2iUq9jh74muDMWk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MXN8RgK2iUq9jh74muDMWk
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: f31c0e5e-7938-4081-975f-7406cbeb81ba

📥 Commits

Reviewing files that changed from the base of the PR and between b83c36e and 1ccfaa0.

📒 Files selected for processing (5)
  • README.md
  • includes/UpgradeGroups.php
  • maintenance/ChangeMediaWikiVersion.php
  • maintenance/ManageUpgradeGroups.php
  • maintenance/UpgradeWiki.php
 ________________________________________
< Your docs say 'TBD'. I'm here to 'Do'. >
 ----------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Zippybonzo
Zippybonzo merged commit aafbd76 into main Sep 22, 2026
0 of 3 checks passed
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.

2 participants