-
Notifications
You must be signed in to change notification settings - Fork 0
Sync additional capabilities filter data to SDS #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: production
Are you sure you want to change the base?
Conversation
…red_capabilities' in Data_Sync class and update related tests accordingly.
|
@andrea-sdl What was this PR for again? Can we close it out or is the work for it almost done? |
|
@pandah3 yes, this should be working properly. It's a way for us to track which custom capabilities a customer has configured. We'll need a change in the backend to ensure we store this in the SDS DB, that part is missing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds syncing of the vip_wsc_forced_mfa_users_additional_capabilities filter data to the Site Details Service (SDS). The implementation detects when the filter is present and extracts the additional capabilities as a comma-separated string.
Key changes:
- Added two new fields to the SDS payload:
has_mfa_additional_capabilities_filter(boolean) andmfa_additional_required_capabilities(comma-separated string) - Added comprehensive test coverage for the new filter detection and data extraction functionality
- Updated test setup/teardown to properly clean up the new filter
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| modules/data-sync/class-data-sync.php | Added logic to detect and extract MFA additional capabilities filter data, updated documentation to reflect the new fields in the SDS payload |
| tests/phpunit/test-data-sync.php | Added filter cleanup in setUp/tearDown, updated default test expectations, added new test for MFA additional capabilities filter, and added test for two-factor entirely disabled scenario |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'has_enable_two_factor_filter' => \has_filter( 'wpcom_vip_enable_two_factor' ) !== false, | ||
|
|
||
| 'has_mfa_additional_capabilities_filter' => $has_additional_capabilities_filter, | ||
| 'mfa_additional_required_capabilities' => $has_additional_capabilities_filter ? implode( ',', apply_filters( Forced_MFA_Users::ADDITIONAL_CAPABILITIES_FILTER_NAME, [] ) ) : '', |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filter result should be normalized before using implode(). If the filter returns a non-array value (e.g., string, null, or object), this will cause a type error. Consider using Capability_Utils::normalize_capabilities_input() like the existing Forced_MFA_Users::get_custom_enforced_capabilities() method does, or at least cast the result to an array.
Example:
'mfa_additional_required_capabilities' => $has_additional_capabilities_filter ? implode( ',', (array) apply_filters( Forced_MFA_Users::ADDITIONAL_CAPABILITIES_FILTER_NAME, [] ) ) : '',Or better yet, use the normalization utility:
'mfa_additional_required_capabilities' => $has_additional_capabilities_filter ? implode( ',', Capability_Utils::normalize_capabilities_input( apply_filters( Forced_MFA_Users::ADDITIONAL_CAPABILITIES_FILTER_NAME, [] ) ) ) : '',
Description
This PR adds syncing of the
wpcom_vip_wsc_forced_mfa_users_additional_capabilitiesfilter to SDS, sending two new fieldshas_mfa_additional_capabilities_filterif there's a functionmfa_additional_required_capabilitiesthe contents of the additional capabilities.Pre-review checklist
Please make sure the items below have been covered before requesting a review:
Pre-deploy checklist
Steps to Test
Add this filter to the
vip-security-boost.phpfileApply (somewhere) the SDS filter via
Verify that the
test_dataoutput contains the new fields.