XML-RPC: wp_editTerm, check 4th arg is an array#12628
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
This PR hardens the wp.editTerm XML-RPC method against invalid/missing “content struct” input to prevent PHP 8+ fatals, and adds PHPUnit coverage for the new behavior.
Changes:
- Make
$content_structretrieval tolerant of a missing index to avoid notices/fatals. - Add a type check so a non-array content struct is rejected with an
IXR_Errorinstead of triggering a PHP 8+ fatal. - Add unit tests covering non-array and missing content struct scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/wp-includes/class-wp-xmlrpc-server.php |
Adds defensive handling for $args[4] and validates the content struct type before reading taxonomy data. |
tests/phpunit/tests/xmlrpc/wp/editTerm.php |
Adds regression tests ensuring invalid/missing content struct inputs return XML-RPC errors instead of fatals. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/wp-includes/class-wp-xmlrpc-server.php:2219
$content_struct['taxonomy']is accessed without verifying the key exists. If the client passes an empty/partial struct (e.g.array()), this will trigger an "Undefined array key 'taxonomy'" notice on PHP 8+ even though the method ultimately returnsInvalid taxonomy.. Consider guarding the key (and short-circuiting) to avoid emitting notices for malformed requests.
if (
! is_array( $content_struct )
|| empty( $content_struct['taxonomy'] )
|| ! taxonomy_exists( $content_struct['taxonomy'] )
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
https://core.trac.wordpress.org/ticket/65682
AI assistance: Yes
Tool(s): Claude
Model(s): Opus 4.8
Used for: Writing the unit tests
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.