close
Skip to content

Groups: add site-provisioning admin tool, fix invisible settings modal, fix dbDelta schema bug - #1848

Merged
bor0 merged 6 commits into
productionfrom
add/group-site-provisioning
Aug 6, 2026
Merged

Groups: add site-provisioning admin tool, fix invisible settings modal, fix dbDelta schema bug#1848
bor0 merged 6 commits into
productionfrom
add/group-site-provisioning

Conversation

@bor0

@bor0 bor0 commented Aug 4, 2026

Copy link
Copy Markdown
Member

Fixes #1782

Summary

  • Add Group site provisioning (Group creation flow with a predefined template #1782): a Network Admin > Sites > Add Group Site screen for deputies to create a fully configured Group site (theme, timezone, Members page, organiser) instead of hand-running wp_insert_site()/wp site create on the sandbox.
  • Fix invisible "Set up your group" modal: current_user_can_manage_events() used a role-array check that didn't recognize super-admin capability elevation the way current_user_can_manage_group_settings() does, so a super admin without an explicit editor/admin role on a given group saw the settings button but the modal rendered with no CSS (mounted in the DOM, but invisible — position: static, transparent background).
  • Fix a pre-existing dbDelta schema bug in wordcamp-payments-network: a missing comma between two KEY definitions corrupted dbDelta()'s index diffing, generating a malformed ALTER TABLE ... ADD `` (``) query that fataled every Network Admin page load on any install still missing the last_modified index. Found while verifying the above through the actual browser UI.

Test plan

Automated

  • Test_Group_Site_Provisioning (happy path, duplicate slug, unknown organizer, invalid slug) — new, passing.
  • Test_Groups_Capabilities::test_super_admin_can_manage_events_despite_subscriber_role — new regression test, passing.
  • Full "WordCamp Groups" PHPUnit suite (54 tests) — passing.
  • BASE_REF=production php .github/bin/phpcs-branch.php — clean.

Manual (local dev — events.wordpress.test)

Steps below use the local Docker dev domain (events.wordpress.test); on a real deploy substitute events.wordpress.org.

Group site provisioning

  1. As a network admin/deputy, go to Network Admin > Sites > Add Group Site on the Groups network (events.wordpress.test/group/wp-admin/network/sites.php?page=add-group-site).
  2. Fill in a group name, slug, an existing user's WordPress.org username as lead organiser, and a timezone. Submit.
Screenshot 2026-08-04 at 13 02 41
  1. Confirm: success notice with working Dashboard/Visit links; the new site appears in Network Admin > Sites at events.wordpress.test/group/{slug}/.
  2. Visit the new site: confirm the groups-site theme is active, /members/ resolves (not a 404) and lists the organiser, and there's no leftover "Hello world!"/"Sample Page" boilerplate.
Screenshot 2026-08-04 at 13 02 51
  1. Log in as the organiser: confirm the "Set up your group" nudge still appears (i.e. blogdescription was left blank on purpose).
  2. Re-submit the form with the same slug — confirm it's rejected with "That slug is already in use by another group." and no second site is created.

Settings modal visibility

  1. As a network super admin who is not an explicit editor/admin on a given group site (e.g. just a subscriber/member there), open that group's front page.
  2. Click Set up your group (or Settings, if the group is already configured).
  3. Before this fix: nothing visibly happens (the modal mounts with no styling and is invisible). After this fix: the full-screen settings modal renders normally with tabs (Events/Venues/Members/Design/About).

dbDelta fix
This only manifests on an install whose {prefix}wcbd_sponsor_invoice_index table already exists but predates the last_modified index (i.e. wcbdsi_database_version site option < 4 on a given network). On such an install, before this fix, any Network Admin page load fatals with WordPress database error: ... ALTER TABLE ... ADD `` (``); after this fix, dbDelta() correctly generates ALTER TABLE ... ADD KEY last_modified (last_modified) and Network Admin loads normally on every network.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

bor0 and others added 3 commits August 4, 2026 12:54
Deputies previously had to hand-run wp_insert_site or wp site create
to get a new site on the Groups network, since no creation flow
existed. Adds a Network Admin > Sites > Add Group Site screen that
creates the site, switches it to the groups-site theme, strips the
default WP boilerplate content, and seeds the Members page the
theme's template needs, all gated behind manage_sites.

See #1782.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…role

current_user_can_manage_events() checked the user's role array
directly instead of calling current_user_can(), so it didn't pick up
core's super-admin capability elevation the way
current_user_can_manage_group_settings() does. A super admin whose
nominal role on a given group is subscriber (e.g. a deputy checking in
on a group they don't personally organise) would see the "Set up your
group" button, but Modal::enqueue_supplementary_assets() -- gated on
current_user_can_manage_events() -- never enqueued the
wp-components/wp-block-editor styles the modal needs, so it rendered
with no CSS and was effectively invisible.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The sponsor-invoice-index table schema was missing a comma between two
KEY definitions, which corrupted dbDelta's index diffing and made it
emit a malformed ALTER TABLE ... ADD `` (``) query. Since
upgrade_database() runs on every network-admin page load until the
version bump succeeds, this fataled every Network Admin screen on
every network on any install still missing the last_modified index.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Add missing docblock on Test_Group_Site_Provisioning::wpSetUpBeforeClass().
- Replace the direct $GLOBALS['super_admins'] override (prohibited by
  WordPress.WP.GlobalVariablesOverride) with grant_super_admin()/
  revoke_super_admin(), resetting the site_admins site option to a
  clean array first since other tests in the suite can leave it in a
  shape grant_super_admin() doesn't expect.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Groups-network provisioning tool and related regressions/tests, while also addressing two production-impacting issues: super-admin capability detection in the Groups frontend and a dbDelta() schema bug in wordcamp-payments-network.

Changes:

  • Add a Network Admin → Sites → “Add Group Site” screen plus create_group_site() helper to provision preconfigured group sites.
  • Fix “invisible settings modal” root cause by treating super admins as event managers in current_user_can_manage_events(), and add a regression test.
  • Fix malformed dbDelta() schema (missing comma between KEY definitions) that could generate invalid ALTER TABLE SQL.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
public_html/wp-content/plugins/wordcamp-payments-network/includes/sponsor-invoices-dashboard.php Fixes SQL schema formatting so dbDelta() index diffs don’t generate malformed ALTERs.
public_html/wp-content/mu-plugins/wporg-groups-frontend/inc/capabilities.php Updates event-management permission helper to explicitly recognize super admins.
public_html/wp-content/mu-plugins/wporg-groups-frontend/tests/test-capabilities.php Adds regression coverage for super-admin-with-subscriber-role behavior (needs cleanup hardening).
public_html/wp-content/mu-plugins/groups/tests/test-group-site-provisioning.php Adds PHPUnit coverage for group-site provisioning flows (one assertion needs strengthening).
public_html/wp-content/mu-plugins/groups/tests/bootstrap.php Ensures required MU-plugin files (logger + provisioning code) are loaded in the suite.
public_html/wp-content/mu-plugins/groups/group-site-provisioning.php Implements the admin UI + provisioning logic (needs timezone validation + Members page error handling).

Comment thread public_html/wp-content/mu-plugins/groups/group-site-provisioning.php Outdated
- Validate `timezone_string` against `timezone_identifiers_list()` in
  `create_group_site()` and fail early with `invalid_timezone` --
  previously an invalid identifier would be persisted unvalidated and
  could later throw when WordPress calls `wp_timezone()`.
- Check the Members page `wp_insert_post()` result and log
  `members_page_failed` if it errors, instead of silently ignoring it.
- Strengthen `test_rejects_unknown_organizer()` to assert no new site
  was created (matching the duplicate-slug test), rather than checking
  for a page slug the success path would never create anyway.
- Guarantee `revoke_super_admin()` runs in the super-admin regression
  test even if the assertion fails, so the test user's super-admin
  status can't leak into later tests in the suite.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@bor0
bor0 requested a review from raicem August 4, 2026 11:21
@bor0
bor0 merged commit 6d00fe8 into production Aug 6, 2026
6 checks passed
@bor0
bor0 deleted the add/group-site-provisioning branch August 6, 2026 10:42
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.

Group creation flow with a predefined template

2 participants