Skip to content

Sponsors: include central and unrecorded PDFs in the agreement backfill - #2098

Merged
KokkieH merged 2 commits into
productionfrom
sponsors/central-post-type
Sep 22, 2026
Merged

KokkieH merged 2 commits into
productionfrom
sponsors/central-post-type

Conversation

@KokkieH

@KokkieH KokkieH commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #1992.

  • get_sponsor_post_types() named central's sponsor post type as mes_sponsor; it is mes.
  • wp wc-sponsor-agreements scan/backfill now also find a PDF attached to a sponsor that the sponsor's meta doesn't name, matching what the upload hook does for new files.
  • Tests cover both.

Testing

Run from the repo root, with WP="docker compose exec -T wordcamp.test wp".

  1. vendor/bin/phpunit --testsuite "WordCamp MU Plugins" --group sponsor-agreements passes.
  2. On an event site, create a sponsor and attach a PDF to it without recording it as the agreement:
    $WP --url=https://seattle.wordcamp.test/2023 post create --post_type=wcb_sponsor --post_status=publish --post_title=Acme --porcelain
    $WP --url=https://seattle.wordcamp.test/2023 media import tmp/agreement.pdf --post_id=<sponsor> --porcelain
    $WP --url=https://seattle.wordcamp.test/2023 post get <attachment> --fields=post_status,post_parent
    
    If the status isn't inherit, reset it: post update <attachment> --post_status=inherit and post meta delete <attachment> _wcorg_sponsor_agreement.
  3. $WP wc-sponsor-agreements scan --verbose lists the site. $WP --url=... wc-sponsor-agreements backfill reports the attachment as Private: yes, and post get <attachment> --field=post_status is now private.
  4. On central, create a sponsor and record an agreement on it:
    $WP --url=https://central.wordcamp.test post create --post_type=mes --post_status=publish --post_title=Acme --porcelain
    $WP --url=https://central.wordcamp.test media import tmp/agreement.pdf --post_id=<sponsor> --porcelain
    $WP --url=https://central.wordcamp.test post meta add <sponsor> mes_sponsor_agreement <attachment>
    
    post get <attachment> --field=post_status is private. On production it stays inherit.

- Name central's sponsor post type as `mes`
- Have the backfill query also find PDFs attached to a sponsor
- Cover both in the tests

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@KokkieH
KokkieH marked this pull request as ready for review September 22, 2026 07:22
@KokkieH
KokkieH requested review from bor0, gedex and mcliwanow September 22, 2026 07:22
@bor0

bor0 commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Checked this out locally and ran through it. The post type rename is right: MES_Sponsor::POST_TYPE_SLUG is mes, and mes_sponsor only ever existed as a $GLOBALS key. Confirmed the before/after on central.wordcamp.test and on seattle.wordcamp.test/2023 following your testing steps, and both behave as described.

Also traced the array_merge( $meta_keys, $post_types, $post_types ) placeholders and it lines up, six for six in textual order.

Updated for c8486349e — all three suggestions taken, re-ran everything, LGTM.

--group sponsor-agreements is green at 48 tests (was 47, the extra is the new data-provider row). The full WordCamp MU Plugins suite has one failure in Test_QuickBooks_OAuth_State, but it fails the same way on production with this branch stashed, so it's not from here. phpcs is clean.

To check the new row pins what it's for, I reverted get_sponsor_post_types() to 'mes_sponsor' on this head and re-ran: three failures, one per central path — the unrecorded-PDF case, the meta-key case, and the runtime hook. Before the new row, the unrecorded path was only exercised against wcb_sponsor, so it does close a real cell.

One correction to what I said earlier: I called capability_type "the one attribute of the real type the fixture doesn't have that any of this reads". It is read, via is_sponsor_upload(), but no test currently routes an upload through a mes parent — test_the_upload_hooks_decline_other_requests hardcodes the wcb_sponsor ternary — so the fixture change is fidelity for a future test rather than coverage today. Still worth having. Dropping rest_base is safe: nothing dispatches /wp/v2/mes, and the real type sets none anyway.

Non-blocking follow-up if you ever want it: parameterising the 'cannot edit the sponsor' row of data_requests_the_upload_hooks_decline by parent type would exercise central's gate too. Though with the editor/author roles the suite uses, edit_others_pages and edit_others_posts coincide, so it'd pin the mapping rather than catch anything. Genuinely take it or leave it.

Unrelated, noticed while confirming the slug: multi-event-sponsors/bootstrap.php:21-22 assigns $GLOBALS['mes_sponsor'] twice, so MES_Region() is overwritten by MES_Sponsor() on the next line. Nothing seems to read it, but it's probably where the wrong slug came from originally — might be worth a separate one-liner.

- Give the `mes` test fixture the capabilities of the real registration
- Test the unrecorded-PDF query against both sponsor post types
- Note which query arm each set of placeholder values feeds

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@bor0 bor0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving on c8486349e. Details are in my comment above: both fixes verified locally, the mutation check confirms the new data-provider row pins the central paths, and CI is green.

Nothing blocking. The one follow-up I mentioned is genuinely optional and I would not hold this for it.

@KokkieH
KokkieH merged commit 429e3a3 into production Sep 22, 2026
5 checks passed
@KokkieH
KokkieH deleted the sponsors/central-post-type branch September 22, 2026 10:03
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