XML-RPC: mw_newMediaObject, check 4th arg is an array#12482
XML-RPC: mw_newMediaObject, check 4th arg is an array#12482josephscott wants to merge 3 commits into
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. |
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. |
There was a problem hiding this comment.
Pull request overview
This PR hardens the XML-RPC mw_newMediaObject endpoint to avoid fatals when the 4th argument (attachment data struct) is not an array, and adds a PHPUnit regression test for that case.
Changes:
- Add an
is_array()guard for$args[3]inwp_xmlrpc_server::mw_newMediaObject()and return anIXR_Error( 400, ... )for invalid data. - Add a unit test asserting that passing a non-array 4th argument returns an
IXR_Errorinstead of triggering a fatal.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/phpunit/tests/xmlrpc/wp/uploadFile.php | Adds a regression test for non-array attachment data passed to mw_newMediaObject. |
| src/wp-includes/class-wp-xmlrpc-server.php | Adds input validation to return an IXR_Error when attachment data is not an array. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
The test failures appear unrelated to this change. |
https://core.trac.wordpress.org/ticket/65611
AI assistance: Yes
Tool(s): Claude
Model(s): Opus 4.8
Used for: Writing the unit test
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.