diff --git a/projects/plugins/jetpack/.phan/baseline.php b/projects/plugins/jetpack/.phan/baseline.php index 9835c9f32cc96..73b08dec3ed91 100644 --- a/projects/plugins/jetpack/.phan/baseline.php +++ b/projects/plugins/jetpack/.phan/baseline.php @@ -251,7 +251,7 @@ 'json-endpoints/class.wpcom-json-api-list-posts-endpoint.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'], 'json-endpoints/class.wpcom-json-api-list-posts-v1-1-endpoint.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternalReal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'], 'json-endpoints/class.wpcom-json-api-list-posts-v1-2-endpoint.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternalReal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'], - 'json-endpoints/class.wpcom-json-api-list-roles-endpoint.php' => ['PhanDeprecatedPartiallySupportedCallable', 'PhanNoopNew', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypeSuspiciousNonTraversableForeach'], + 'json-endpoints/class.wpcom-json-api-list-roles-endpoint.php' => ['PhanDeprecatedPartiallySupportedCallable', 'PhanNoopNew', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn'], 'json-endpoints/class.wpcom-json-api-list-shortcodes-endpoint.php' => ['PhanNoopNew', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn'], 'json-endpoints/class.wpcom-json-api-list-terms-endpoint.php' => ['PhanNoopNew', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypeSuspiciousNonTraversableForeach'], 'json-endpoints/class.wpcom-json-api-list-users-endpoint.php' => ['PhanNoopNew', 'PhanRedundantCondition', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanUndeclaredProperty'], diff --git a/projects/plugins/jetpack/changelog/update-use-instance-of-for-checking-wp-roles b/projects/plugins/jetpack/changelog/update-use-instance-of-for-checking-wp-roles new file mode 100644 index 0000000000000..701ce50fb2866 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-use-instance-of-for-checking-wp-roles @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Change done to avoid fatal in wpcom when using v1 endpoint with force wpcom param diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-roles-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-roles-endpoint.php index 582cede0c01bb..061a4372ef056 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-roles-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-list-roles-endpoint.php @@ -124,7 +124,7 @@ public function callback( $path = '', $blog_id = 0 ) { return new WP_Error( 'unauthorized', 'User cannot view roles for specified site', 403 ); } - if ( method_exists( $wp_roles, 'get_names' ) ) { + if ( $wp_roles instanceof WP_Roles ) { $role_names = $wp_roles->get_names(); $role_keys = array_keys( $role_names ); @@ -134,7 +134,7 @@ public function callback( $path = '', $blog_id = 0 ) { $role_details->display_name = translate_user_role( $role_names[ $role_key ] ); $roles[] = $role_details; } - } else { + } elseif ( is_array( $wp_roles ) ) { // Jetpack Shadow Site side of things. foreach ( $wp_roles as $role_key => $role ) { $roles[] = (object) array(