-
Notifications
You must be signed in to change notification settings - Fork 116
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
check assignee on task #526
base: develop
Are you sure you want to change the base?
check assignee on task #526
Conversation
WalkthroughThe pull request introduces a modification to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/Task/Controllers/Task_Controller.php (1)
167-169
: Improve input validation and error handling for assignees.The change correctly handles non-array input and ensures type safety. However, consider these improvements:
- Add input validation to reject invalid assignee values
- Log warnings when invalid input is received
- Document the expected input format
Apply this diff to enhance the validation:
- $assignees = is_array($request->get_param('assignees')) ? - array_map('intval', $request->get_param('assignees')) : []; - + $raw_assignees = $request->get_param('assignees'); + $assignees = []; + + if (is_array($raw_assignees)) { + foreach ($raw_assignees as $assignee) { + $assignee_id = intval($assignee); + if ($assignee_id > 0) { + $assignees[] = $assignee_id; + } else { + error_log(sprintf( + 'Invalid assignee value "%s" provided in task creation', + esc_html($assignee) + )); + } + } + } else { + error_log(sprintf( + 'Invalid assignees format provided in task creation. Expected array, got %s', + gettype($raw_assignees) + )); + }Consider adding PHPDoc to document the expected format:
/** * Store a new task. * * @param WP_REST_Request $request Request object * @return WP_REST_Response * * @throws WP_Error * * Expected format for assignees parameter: * array<int> List of user IDs to assign to the task * Example: [1, 2, 3] */
Added empty assignee check
Summary by CodeRabbit