Skip to content

XML-RPC: mw_newMediaObject, check 4th arg is an array#12482

Open
josephscott wants to merge 3 commits into
WordPress:trunkfrom
josephscott:65611/xmlrpc-mw-newmediaobject-args
Open

XML-RPC: mw_newMediaObject, check 4th arg is an array#12482
josephscott wants to merge 3 commits into
WordPress:trunkfrom
josephscott:65611/xmlrpc-mw-newmediaobject-args

Conversation

@josephscott

Copy link
Copy Markdown
Contributor

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.

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props josephscott, mukesh27.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copilot AI left a comment

Copy link
Copy Markdown

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 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] in wp_xmlrpc_server::mw_newMediaObject() and return an IXR_Error( 400, ... ) for invalid data.
  • Add a unit test asserting that passing a non-array 4th argument returns an IXR_Error instead 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.

Comment thread src/wp-includes/class-wp-xmlrpc-server.php Outdated
Comment thread tests/phpunit/tests/xmlrpc/wp/uploadFile.php
josephscott and others added 2 commits July 13, 2026 13:46
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@josephscott

Copy link
Copy Markdown
Contributor Author

The test failures appear unrelated to this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants