Skip to content

Conversation

@pfefferle
Copy link
Member

@pfefferle pfefferle commented Aug 5, 2025

Wrap actor retrieval in is_wp_error checks in both Followers_Controller and Following_Controller to prevent invalid actors from being included in orderedItems. Uses array_filter to remove any failed lookups, improving robustness of REST responses.

Related #2053

Proposed changes:

  • Added error checking for actor retrieval in both controllers
  • Used array_filter to remove failed actor lookups from the response
  • Maintained consistent behavior across followers and following endpoints

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Go to '..'

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Improves REST responses by skipping invalid actors in Followers and Following controllers.

Wrap actor retrieval in is_wp_error checks in both Followers_Controller and Following_Controller to prevent invalid actors from being included in orderedItems. Uses array_filter to remove any failed lookups, improving robustness of REST responses.
Copilot AI review requested due to automatic review settings August 5, 2025 09:27
Copy link

Copilot AI left a 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 improves error handling in the followers and following REST API endpoints by preventing invalid actors from appearing in the response. The change wraps actor retrieval calls with error checking to handle cases where Actors::get_actor() returns a WP_Error object.

Key changes:

  • Added error checking for actor retrieval in both controllers
  • Used array_filter to remove failed actor lookups from the response
  • Maintained consistent behavior across followers and following endpoints

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
includes/rest/class-followers-controller.php Added error handling to filter out invalid actors from followers list
includes/rest/class-following-controller.php Added error handling to filter out invalid actors from following list

pfefferle and others added 6 commits August 5, 2025 11:36
Replaces unqualified calls to array_map and is_wp_error with their fully qualified counterparts (\array_map, \is_wp_error) in Followers_Controller and Following_Controller. This change improves code clarity and prevents potential issues with function overrides or namespace conflicts.
@pfefferle pfefferle merged commit 853a952 into trunk Aug 6, 2025
12 checks passed
@pfefferle pfefferle deleted the fix/2053 branch August 6, 2025 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants