Repository navigation
Closes #1322: Restore per-site MCP abilities on multisite, fix restore-media error and network admin notice - #1352
remyperona wants to merge 7 commits into
Conversation
…activated multisite Add a manage-site capacity describer so site admins keep the abilities that act on their own site; network-wide abilities and custom folders stay network-only. Fix restore-media treating any custom-folders ID as known, trim account details for site-only callers, and show the MCP Adapter migration notice in the network admin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rk-activated legs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| UnusedCode | 1 medium |
🟢 Metrics 17 complexity · 0 duplication
Metric Results Complexity 17 Duplication 0
🟢 Coverage 77.08% diff coverage
Metric Results Coverage variation Report missing for 89848811 Diff coverage ✅ 77.08% diff coverage (50.00%) Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (8984881) Report Missing Report Missing Report Missing Head commit (d0cbfa1) 20635 2809 13.61% Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#1352) 48 37 77.08% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Note Generated by the AI delivery pipeline (lead-reviewer · Claude Opus 5.5). Review: ✅ PASS All three earlier blockers are resolved in d80823a, 86ad2d3 and fe27091: the next-gen impact |
|
Note Generated by the AI delivery pipeline (qa-engineer · Claude Opus 5.5). QA: ✅ PASS (re-QA at fe27091; first run was PARTIAL on a docs cell, now corrected) Tested on a converted wp-env multisite (WP 6.9.6, subdirectory network, subsite
Network-activated, subsite admin on Per-site activation: the subsite admin and the super admin are allowed on everything except that the site admin is denied Notice: the super admin, with Blockers: none. Re-QA at fe27091: every matrix row in docs/api/mcp.md was compared with observed WP-CLI results for a site admin of /test1/ and a super admin, network-activated and per-site; all match, including bulk-optimize custom-folders denied for the site admin in both modes and generate-missing-nextgen allowed in both. Criteria 3 and 4 are unchanged at HEAD (restore 999999 returns Environment notes (not PR defects):
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a error Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…om folders Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…isite Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note Generated by the AI delivery pipeline (lead-reviewer · standalone). Review: PASS No blockers. Per-site abilities correctly use the new Inline findings (not posted):
Nice-to-haves:
Cross-file check: Tests: PASS. Unit and integration tests cover the capability matrix, unknown-ID restore, the notice and the guard responses. CI now runs these in multisite and network-activated jobs. suppressed: gh pr comment 1352 --body-file .TemporaryItems/Issues/imagify-plugin/review/1322.md |
|
@remyperona I think it's worth checking the inline-finding & Nice-to-haves |
…and document the opt-out The two deny-only passes for 'manage-site' each looked up the 'manage' capacity, so imagify_capacity fired three times for 'manage' in one check. It is now resolved once for both passes, and the docblocks state how often each filter runs. docs/api/mcp.md claimed a customized 'manage' could never be bypassed. A filter that returns manage_network_options for 'manage' looks like the default, so site admins still get the per-site abilities. The docs now say so and show the supported opt-out: filter imagify_capacity for 'manage-site'. Tests cover the opt-out, the documented limitation and the call count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note Generated by the AI delivery pipeline (Claude Opus 5.5). @jeawhanlee thanks for the review. Here's how each point was handled. The fixes are in d0cbfa1. Inline findings
Nice-to-haves: kept as they are
Tested in wp-env: the Context, Abilities and MCP integration groups on single site, multisite and network-activated, plus unit tests and PHPStan. All pass. |
Closes #1322
Description
Restores the per-site MCP abilities for subsite admins on network-activated multisite (lost in #1302), fixes
restore-mediareturning a permission error for unknown IDs, and shows the MCP migration notice in network admin. Network-wide abilities and custom-folders bulk optimization stay super-admin only.Type of change
Detailed scenario
What was tested
QA passed all 6 acceptance criteria on a wp-env multisite, with Imagify both network-activated and activated per site. The QA report has the per-ability results and the two rows checked only by integration tests. Locally, the unit tests, the single-site and multisite integration tests, and the network-activated integration tests all pass, and CI is green.
How to test
On a multisite with Imagify network-activated, as an admin of one subsite only (not a super admin):
bulk-optimize(wp) andgenerate-missing-nextgenare allowed.bulk-optimize(custom-folders),get-settings,update-settings,get-account,get-statsandget-nextgen-coverageare denied.restore-mediawithmedia_id999999 returnsInvalid media..mcp_refresh_jti_<user>meta and no MCP Adapter plugin, the migration notice shows on/wp-admin/network/and links to the network plugin installer.Affected Features & Quality Assurance Scope
MCP abilities (
classes/Abilities), capability contexts (classes/Context, NextGEN context), the MCP migration notice, the multisite CI jobs.Technical description
Documentation
docs/api/mcp.mdhas the role table for each ability and explains themanage-sitecapability.manage-sitecapability inContext\WP. On network-activated installs it maps tomanage_options, unlessimagify_capacitycustomizesmanage. In every other case it behaves exactly likemanage.AbstractContext::user_can()runs a second, deny-only filter pass formanage, so filters keyed on'manage'still deny access and can never grant it. As a result, filters may run twice and must be idempotent.AbstractAbility::has_site_manage_permission()check. Responses to a subsite admin leave out quota, reset date, upgrade link and custom-folder counts.restore-media: an ID only counts as a custom-folder file if it exists in the custom-folders table.AdapterNotice: also hooked tonetwork_admin_notices.New dependencies
None.
Risks
Invalid media.to everyone. Admins with network access used to getThis media is not optimized….Mandatory Checklist
Code validation
Code style
Unticked items justification
None.
Additional Checks
🤖 Generated with Claude Code