refactor: extract shared user utilities across REST API controllers#3
refactor: extract shared user utilities across REST API controllers#3xavierandueza wants to merge 1 commit into
Conversation
Introduce a new WP_REST_User_Utilities class that centralizes common user validation, permission checking, and multisite membership logic previously duplicated across multiple REST API controllers. Refactors WP_REST_Users_Controller, WP_REST_Application_Passwords_Controller, and WP_REST_Settings_Controller to use the shared utilities.
|
📚 Documentation update workflow has been queued for reopened PR (Job ID: |
📊 PR Analysis SummaryFiles Changed: 5 file(s) Changed Files
Relevant Documentation PagesDocs impacted by this PR
✅ Documentation Changes Applied
This analysis was automatically generated by the ReadMe AI Documentation Bot. |
|
📚 Documentation update workflow has been queued for reopened PR (Job ID: |
📊 PR Analysis SummaryFiles Changed: 5 file(s) Changed Files
Relevant Documentation PagesDocs impacted by this PR
ℹ️ Documentation UpdatesNo automatic documentation updates were applied. This analysis was automatically generated by the ReadMe AI Documentation Bot. |
|
📚 No documentation updates were needed for this PR. |
|
📚 No documentation updates were needed for this PR. |
|
📚 No documentation updates were needed for this PR. |
|
📚 No documentation updates were needed for this PR. |
|
📚 Analyzing PR for documentation updates... |
|
📚 Analyzing PR for documentation updates... |
|
📚 Analyzing PR for documentation updates... |
|
📚 No documentation updates were needed for this PR. |
|
📚 Analyzing PR for documentation updates... |
|
📚 No documentation changes were needed for this PR (Job ID: |
|
You can re-trigger by reopening this PR. |
|
📚 No documentation changes were needed for this PR (Job ID: |
|
📚 No documentation updates were needed for this PR. |
1 similar comment
|
📚 No documentation updates were needed for this PR. |
|
📚 No documentation changes were needed for this PR (Job ID: |
|
📚 No documentation changes were needed for this PR (Job ID: |
|
📚 No documentation changes were needed for this PR (Job ID: |
|
📚 No documentation changes were needed for this PR (Job ID: |
|
📚 No documentation changes were needed for this PR (Job ID: |
Summary
Introduces a new
WP_REST_User_Utilitiesclass that centralizes duplicated user-related logic shared across REST API controllers. This consolidates user ID validation, current user resolution, multisite membership checks, and permission checking into reusable static methods.Refactors
WP_REST_Users_Controller,WP_REST_Application_Passwords_Controller, andWP_REST_Settings_Controllerto use the shared utilities, reducing code duplication.Changes
New file:
wp-includes/rest-api/class-wp-rest-user-utilities.php— shared utility class with methods forvalidate_user_id(),resolve_current_user(),check_multisite_membership(),check_permission(), andhas_capability()Modified files:
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php—get_user(),get_current_item(),create_item_permissions_check(), anddelete_item_permissions_check()now delegate to the shared utilitywp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php—get_user()and six permission check methods refactored to use shared utilitieswp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php— permission check updated to use shared capability helperwp-settings.php— registers the new utility class