Skip to content

Participation Notifier: Campus Connect organizers should be automatically assigned their own badge instead of the WordCamp Organizer badge - #2216

Open
coffee2code wants to merge 3 commits into
WordPress:productionfrom
coffee2code:change/assign-campus-connect-organizer
Open

coffee2code wants to merge 3 commits into
WordPress:productionfrom
coffee2code:change/assign-campus-connect-organizer

Conversation

@coffee2code

Copy link
Copy Markdown

Summary

Campus Connect organizers currently receive the same wordcamp-organizer profiles.w.org badge as WordCamp organizers. Per meta#8318, a new Campus Connect Organizer badge was created to recognize Campus Connect organizers, so they should get the campus-connect-organizer badge instead.

  • When building the association payload for a published wcb_organizer post, look up the site’s Central wordcamp post and use event_subtype === campusconnect to choose campus-connect-organizer vs wordcamp-organizer.
  • Track each association with its own usermeta prefix (wc_wcb_organizer_* vs wc_campus_connect_organizer_*) so add/remove counts stay independent when someone organizes both event types.
  • Ship a one-time WP-CLI migration (wp wc-cc-organizer-meta migrate) that:
    1. Renames any legacy Campus Connect organizer usermeta keys that still use the WordCamp prefix.
    2. Ensures each Campus Connect organizer has the campus-connect-organizer Profiles association.
    3. Removes wordcamp-organizer when they have no remaining WordCamp organizer usermeta (they were incorrectly given that badge before association selection was subtype-aware).
      Mixed organizers keep wordcamp-organizer. --dry-run reports the same usermeta and badge actions without writing or calling Profiles.
    4. Same disposable pattern as the other wp-cli-commands backfills: delete the command file (and its bootstrap require) after it has been run on production.
  • Add a PHPUnit suite for the notifier: permanent association/prefix coverage, plus migration tests (including badge reconciliation) that mark incomplete (not fail) if the CLI file has already been removed.

How to review this PR

  1. wordcamp-participation-notifier.php — association selection + meta-key prefixes (the lasting change).
  2. wp-cli-commands/migrate-campus-connect-organizer-meta.php — one-time usermeta rename + Profiles badge add/remove; safe to re-run / --dry-run.
  3. tests/test-campus-connect-organizer-association.php vs tests/test-migrate-campus-connect-organizer-meta.php — permanent vs disposable coverage.

Test plan

  • phpunit — WordCamp Participation Notifier suite (association + migration / badge reconciliation)
  • phpcs on touched PHP files
  • Manual / sandbox: publish a Campus Connect organizer → campus-connect-organizer association
  • Manual / sandbox: publish a WordCamp organizer → still wordcamp-organizer
  • After deploy: wp wc-cc-organizer-meta migrate --dry-run, then without --dry-run, on production/staging

Manual test steps

  1. On a Campus Connect event site, publish an organizer post with a test w.org username. Confirm profiles receives campus-connect-organizer (not wordcamp-organizer).
  2. On a typical WordCamp site, publish an organizer the same way. Confirm wordcamp-organizer is unchanged.
  3. For a user who organizes both types, remove them from the Campus Connect post only. Confirm the Campus Connect badge is removed and the WordCamp badge remains (and the reverse).
  4. Run wp wc-cc-organizer-meta migrate --dry-run. Confirm it reports:
    • legacy key renames
    • would add campus-connect-organizer for affected organizers
    • would remove wordcamp-organizer only when they have no remaining WordCamp organizer associations
  5. Run the migration for real. Confirm usermeta keys are renamed, Profiles associations match the dry-run report, and WordCamp-site keys / mixed organizers’ wordcamp-organizer badges are untouched.

Fixes #2215.

…onnect Organizer badge instead of the WordCamp Organizer badge.

- When building the association payload for a published `wcb_organizer` post, look up the site’s Central `wordcamp` post and use `event_subtype === campusconnect` to choose `campus-connect-organizer` vs `wordcamp-organizer`.
- Track each association with its own usermeta prefix (`wc_wcb_organizer_*` vs `wc_campus_connect_organizer_*`) so add/remove counts stay independent when someone organizes both event types.
- Ship a one-time WP-CLI migration (`wp wc-cc-organizer-meta migrate`) to rename any legacy Campus Connect keys that still use the WordCamp prefix. Same disposable pattern as the other `wp-cli-commands` backfills: delete the command file (and its bootstrap require) after it has been run on production (though safe to re-run).
- Add a PHPUnit suite for the notifier: permanent association/prefix coverage, plus migration tests that mark incomplete (not fail) if the CLI file has already been removed.
…s, also assign/remove badges as needed.

Ensures each Campus Connect organizer has the `campus-connect-organizer` Profiles association, and removes `wordcamp-organizer` when they have no remaining WordCamp organizer usermeta (they were incorrectly given that badge before association selection was subtype-aware).
@maciejpilarski

Copy link
Copy Markdown
Contributor

Thanks for picking this up. I read through the change and have two notes and one question.

1. An event's type changed after organizers were added

A wrangler can change the Event Subtype on Central at any time (class-event-admin.php saves event_subtype on each edit), and the notifier picks the organizer meta prefix from the subtype at the moment of each call. If an event is switched from WordCamp to Campus Connect after its organizers were published:

  • removing one of those organizers looks for wc_campus_connect_organizer_{site}_{post}, finds nothing and returns early, so their wordcamp-organizer badge stays;
  • re-saving an organizer post adds campus-connect-organizer but leaves the old wc_wcb_organizer_ row behind, so they end up with both badges.

Running wp wc-cc-organizer-meta migrate again cleans that up, but the command is meant to be deleted after the production run, so after that nothing would. The reverse change (Campus Connect back to WordCamp) isn't handled by the migration either, since it only renames keys toward the Campus Connect prefix. It's probably rare, so a note in the docblock may be enough, unless you'd rather keep the rename as a permanent helper that runs when event_subtype changes.

2. A branch that can't run in get_post_association_payload()

Inside case 'wcb_organizer':, 'wordcamp' === $post->post_type is never true, because the switch is on $post->post_type. Plain $wordcamp = get_wordcamp_post(); does the same. (It looks copied from get_post_activity_payload(), where the wordcamp case does exist.)

Question: when the badge is given

The badge is given when the organizer post is published on the event site, the same as for WordCamps, which is what comment 8 on meta#8318 suggested. Comments 4 and 7 there asked for it once the event tracker is set to Closed. Is publish time the agreed behavior? I'm asking because with it the badge can show on a profile before the event takes place, or for an event that is later cancelled.

When the migration runs, I'm happy to check the dry-run list against the Campus Connect events we track for the program, if that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Participation Notifier: Campus Connect organizers should be automatically assigned their own badge instead of the WordCamp Organizer badge

2 participants