Skip to content

refactor: extract shared user utilities across REST API controllers#3

Open
xavierandueza wants to merge 1 commit into
masterfrom
xavierandueza/user-api-refactor
Open

refactor: extract shared user utilities across REST API controllers#3
xavierandueza wants to merge 1 commit into
masterfrom
xavierandueza/user-api-refactor

Conversation

@xavierandueza
Copy link
Copy Markdown
Owner

Summary

Introduces a new WP_REST_User_Utilities class 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, and WP_REST_Settings_Controller to 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 for validate_user_id(), resolve_current_user(), check_multisite_membership(), check_permission(), and has_capability()

Modified files:

  • wp-includes/rest-api/endpoints/class-wp-rest-users-controller.phpget_user(), get_current_item(), create_item_permissions_check(), and delete_item_permissions_check() now delegate to the shared utility
  • wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.phpget_user() and six permission check methods refactored to use shared utilities
  • wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php — permission check updated to use shared capability helper
  • wp-settings.php — registers the new utility class

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.
@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Feb 13, 2026

📚 Documentation update workflow has been queued for reopened PR (Job ID: 698f1d19eedcb468ab9b03ac). The documentation bot will propose changes (if relevant) shortly.

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Feb 13, 2026

📊 PR Analysis Summary

Files Changed: 5 file(s)
Additions: +221 lines
Deletions: -127 lines

Changed Files
  • wp-includes/rest-api/class-wp-rest-user-utilities.php
  • wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php
  • wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php
  • wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
  • wp-settings.php

Relevant Documentation Pages

Docs impacted by this PR
  • createuser
  • listusers
  • getuser
  • updatecurrentuser
  • updateuser
  • plugins-controller-classes
  • getcurrentuser
  • plugins-requests
  • plugins-checking-user-capabilities

✅ Documentation Changes Applied

🔗 View changes in ReadMe


This analysis was automatically generated by the ReadMe AI Documentation Bot.

@xavierandueza xavierandueza marked this pull request as ready for review February 13, 2026 13:09
@xavierandueza xavierandueza reopened this Feb 17, 2026
@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Feb 17, 2026

📚 Documentation update workflow has been queued for reopened PR (Job ID: 6994ebd8a0f3185b35c7673c). The documentation bot will propose changes (if relevant) shortly.

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Feb 17, 2026

📊 PR Analysis Summary

Files Changed: 5 file(s)
Additions: +221 lines
Deletions: -127 lines

Changed Files
  • wp-includes/rest-api/class-wp-rest-user-utilities.php
  • wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php
  • wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php
  • wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
  • wp-settings.php

Relevant Documentation Pages

Docs impacted by this PR
  • createuser
  • listapplicationpasswords
  • updatesettings
  • listusers
  • getuser
  • getsettings
  • updateuser
  • createapplicationpassword
  • deleteallapplicationpasswords
  • getapplicationpassword

ℹ️ Documentation Updates

No automatic documentation updates were applied.


This analysis was automatically generated by the ReadMe AI Documentation Bot.

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Feb 20, 2026

📚 No documentation updates were needed for this PR.

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Feb 26, 2026

📚 No documentation updates were needed for this PR.

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Feb 27, 2026

📚 No documentation updates were needed for this PR.

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Mar 1, 2026

📚 No documentation updates were needed for this PR.

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Mar 2, 2026

📚 Analyzing PR for documentation updates...

@readme-agent-staging
Copy link
Copy Markdown

📚 Analyzing PR for documentation updates...

@readme-agent-staging
Copy link
Copy Markdown

📚 Analyzing PR for documentation updates...

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Mar 17, 2026

📚 No documentation updates were needed for this PR.

@readme-agent-staging
Copy link
Copy Markdown

📚 Analyzing PR for documentation updates...

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Mar 17, 2026

📚 No documentation changes were needed for this PR (Job ID: 69b8e4b9a6a191853ca7b9b8).

@readme-agent-staging
Copy link
Copy Markdown

readme-agent-staging Bot commented Mar 17, 2026

⚠️ The documentation bot was unable to apply documentation updates (Job ID: 69b8f73d4404eb041bee772e).

You can re-trigger by reopening this PR.

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Mar 17, 2026

📚 No documentation changes were needed for this PR (Job ID: 69b8f73ee5d787954e07208d).

@readme-agent-staging
Copy link
Copy Markdown

readme-agent-staging Bot commented Mar 26, 2026

📚 No documentation updates were needed for this PR.

1 similar comment
@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Mar 26, 2026

📚 No documentation updates were needed for this PR.

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Apr 1, 2026

📚 No documentation changes were needed for this PR (Job ID: 69cd9dd31f777de526a581fb).

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Apr 8, 2026

📚 No documentation changes were needed for this PR (Job ID: 69d59e0920f2bdc04a099fba).

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Apr 10, 2026

📚 No documentation changes were needed for this PR (Job ID: 69d84a50b65c15926710755c).

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Apr 24, 2026

📚 No documentation changes were needed for this PR (Job ID: 69eb145154bc3310f58c475e).

@readme-pr-app
Copy link
Copy Markdown

readme-pr-app Bot commented Apr 24, 2026

📚 No documentation changes were needed for this PR (Job ID: 69eb15cd54bc3310f58c4786).

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.

1 participant