4. Gate the notice queue on the capability the conflict gate asks for - #56
Conversation
Notices\Presenter asked for activate_plugins unconditionally while Conflict\Gatekeeper asked for manage_network_plugins on multisite. Core folds the two together only while the network keeps the per-site Plugins menu off, so on a network that opened it a site administrator could print a merge notice raised by a super admin's deactivation and clear it -- out of one network option shared by every site -- leaving the only person who could undo the deactivation never told. The shared answer lives in Traits\Guards_Plugin_Capability rather than in either class, for the reason Guards_Hook_Prefix is a trait: the answer comes from current_user_can() either way and all that is shared is which capability to name. A collaborator would want a container binding, a constructor argument on both classes and an interface nothing dispatches on, to carry one boolean; a literal in each class with a docblock in each pointing at the other is what these two already had, and it is what drifted. Raising the consume gate also withholds the dependency notice from a site administrator on multisite. That is right: the queue is one network option either way, so what they were consuming was never only their own site's.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe change adds a shared multisite-aware plugin capability guard. Conflict resolution and notice presentation use the guard. Documentation and tests cover network notice consumption by site and network administrators. ChangesCapability authorization
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The capability check and notice-queue behavior change has no actionable merge-blocking risk remaining based on the supplied evidence and is merge-ready after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
What:
Notices\Presenter::render(), reached fromall_admin_notices, now asks the same capability asConflict\Gatekeeper::user_may_resolve()atplugins_loadedpriority 5, answered once by the newTraits\Guards_Plugin_Capability.Usage:
Why this way:
The queue was written behind one capability and consumed behind a narrower one. It is a single network option and rendering clears it, so a site administrator opening any admin screen drained the merge notice — raised once, never re-queued — before the super admin who authorised the deactivation saw it. It bites only where the per-site Plugins menu is on; elsewhere
map_meta_cap()folds the two gates together by accident, which is why no test caught it.One answer, in a trait, for the reason
Guards_Hook_Prefixis one. All that is shared is which capability to name, so a collaborator would want a binding, a constructor argument on both classes and an interface nothing dispatches on. What it may not be is a literal in each class: that is what shipped, and the two disagreed.Summary by CodeRabbit
Bug Fixes
Documentation