Suggest mode: REST permissions and PHP coverage for note suggestions#78351
Suggest mode: REST permissions and PHP coverage for note suggestions#78351adamsilverstein wants to merge 8 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in e5403ae. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/28144766166
|
2d7db93 to
448a38f
Compare
phase-5a introduces class-wp-rest-comments-controller-gutenberg-test.php, which calls gutenberg_register_block_comment_metadata(). That function lives in lib/compat/wordpress-6.9/block-comments.php, which was only wired in higher up the stack (autosave), so PHP unit tests failed here with "Call to undefined function". Relocate the self-contained file and its require down to where the test first needs it.
ReflectionMethod::setAccessible() is a no-op since PHP 8.1 and emits a deprecation in 8.5 that PHPUnit fails on. Only call it on PHP < 8.1, matching the guard already used higher in the stack.
…-5a-rest-backend # Conflicts: # packages/editor/CHANGELOG.md
|
Size Change: +255 B (0%) Total Size: 7.51 MB 📦 View Changed
|
Overview
One of three replacement PRs for the now-closed #77407. This slice is the REST/PHP backend for the Suggest-mode lifecycle.
Tracking issue: #73411.
What's in this PR
lib/compat/wordpress-6.9/class-gutenberg-rest-comment-controller-6-9.phpoverridesupdate_item_permissions_checkso a user withedit_poston the parent can updatenotecomments — but only for suggestion-lifecycle fields (statuslimited toapproved/hold, plusmeta._wp_suggestion_status). Any other field falls back to core'sedit_commentcheck.auth_callbacks —_wp_suggestionand_wp_suggestion_statusboth authorize onedit_postagainst the parent._wp_suggestionpayload, enforced at the controller before sanitize fires (matching the client-side pre-flight cap).class-wp-rest-comments-controller-gutenberg-test.php: meta round-trip, editor-can-apply, contributor-cannot-apply, restricted-field pass-through, payload-size truncation.Pure backend. No JS, no UI. Safe to merge ahead of the rest of the stack.
Test plan
npm run wp-env run cli -- --env-cwd='wp-content/plugins/gutenberg' vendor/bin/phpunit --filter=WP_Test_REST_Comments_Controller_Gutenberg vendor/bin/phpcs lib/compat/wordpress-6.9/class-gutenberg-rest-comment-controller-6-9.php lib/compat/wordpress-6.9/block-comments.phpManual:
edit_post:PATCH /wp/v2/comments/<id>with{ status: 'approved', meta: { _wp_suggestion_status: 'applied' } }— succeeds.PATCH— 403.PATCHwith{ content: 'rewritten' }— falls back to coreedit_comment.PATCHwith{ status: 'spam' }— falls back to coreedit_comment._wp_suggestionmeta payload > 64 KB — 400.Replaces part of #77407.
🗺️ PR Stack Navigation
_wp_suggestionmeta, provider, sidebar actions📋 Tracking issue: #73411