Opened 9 years ago
Last modified 5 weeks ago
#40863 reopened defect (bug)
WP 4.7.5 XMLRPC new method for parsing arguments omits menu_order
| Reported by: | bjminihan | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | XML-RPC | Version: | 4.7.5 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
In WP 4.7.5, in wp-includes/class-wp-xmlrpc-server.php, on line 1327, this line:
$post_data = wp_parse_args( $content_struct, $defaults );
was changed to:
$post_data = wp_parse_args( array_intersect_key( $content_struct, $defaults ), $defaults );
Unfortunately, the new intersection strips out any arguments from $content_struct that don't exist in $defaults.
So you can no longer edit a post and change the "menu_order" field, because it doesn't exist in the $defaults declared just before this line.
Please provide either an updated list of acceptable defaults (e.g. including menu fields), or allow for additional fields to pass through to wp_parse_args.
Tested with latest version of WP, and confirmed that swapping the changed line above enables/disables the ability to change menu_order in posts.
Attachments (1)
Change History (9)
#2
in reply to: ↑ 1
@
9 years ago
Adding menu_order would solve our problem nicely. Not sure my opinion matters, but I agree the other fields aren't necessary. Thanks
Replying to iworks:
Added two params:
- menu_order
- to_ping
We still have to miss (based on wp_insert_post()) those fields:
- pinged
- import_id
- context
- post_content_filtered
But I'm not sure we should add it.
#WCPL2017
#4
follow-up:
↓ 6
@
9 years ago
- Resolution worksforme
- Status closed → reopened
I assume closing this ticket wasn't intended. Let's also at least add a basic test for this so this wouldn't happen in the future.
#5
@
9 years ago
My apologies, but I'm not aware of the specific process I need to follow. I conducted a test on a site with the above change, and found that it worked perfectly
#6
in reply to: ↑ 4
@
9 years ago
Replying to markoheijnen:
I assume closing this ticket wasn't intended. Let's also at least add a basic test for this so this wouldn't happen in the future.
I'm sorry, but I'm not clear on the process for implementing this change (re-inserting menu_order back into the class-wp-xmlrpc-server.file). Do you know how I would initiate that process?
This ticket was mentioned in PR #14189 on WordPress/wordpress-develop by @salvatorecorsi.
5 weeks ago
#7
- Keywords has-patch has-unit-tests added
wp.newPost and wp.editPost silently discard a supplied menu_order: _insert_post() intersects the content struct with defaults that do not include this field. For example, creating a page with menu_order: 5 stores 0, and editing a page whose order is 10 to menu_order: 0 leaves 10.
Add menu_order with a default of 0 to the existing whitelist and document the parameter. The existing edit merge preserves the stored order when it is omitted. Add integration tests for posts and pages, positive/zero/negative values, and an edit that omits the field.
This follows the whitelist approach in the earlier patch by iworks on the ticket, focusing on the menu_order bug confirmed by the reporter.
Reproduction
- Call
wp.newPostas an editor withpost_title: "Menu order test",post_type: "page", andmenu_order: 5. The saved order should be 5. - Start with a page whose
menu_orderis 10 and callwp.editPostwithmenu_order: 0. The saved order should be 0. - Edit that page with only
post_titleand confirm that its saved order is preserved.
Validation
- Before the implementation change, the new
wp.newPosttests had 3 failures in 4 cases, and thewp.editPosttests had 4 failures in 5 cases. - Native PHPUnit on PHP 8.3.28 and private MariaDB: the full XML-RPC classes passed 359 tests and 1,355 assertions. The create/edit classes separately passed 58 tests and 167 assertions.
- WordPress PHPCS scan of the three changed files: no errors; one existing
PreparedSQL.NotPreparedwarning also reproduced on unchanged trunk. The error-only scan passed. - PHP compatibility scan, PHP syntax checks for all changed files, and
git diff --checkpassed. - No JavaScript/assets changed; build and E2E checks were not run.
The local serialized PHPUnit runner invokes php vendor/bin/phpunit -c phpunit.xml.dist --filter '^Tests_XMLRPC_'. Coding standards and compatibility used php vendor/bin/phpcs --standard=phpcs.xml.dist --parallel=1 <three changed files> and php vendor/bin/phpcs --standard=phpcompat.xml.dist --parallel=1 <three changed files>.
Use of AI Tools
AI assistance: Yes
Tool(s): OpenAI Codex
Model(s): GPT-6
Used for: Ticket investigation, implementation, regression tests, local validation, this description, and an independent automated review. No human review is claimed; this PR is submitted for contributor and maintainer review.
@salvatorecorsi commented on PR #14189:
5 weeks ago
#8
The full PHPUnit workflow passed all 64 PHP/database configurations, including multisite and memcached. E2E, build, PHPStan, compatibility and coding standards also passed.
The five failed upgrade jobs in this run failed during tool setup: setup-php reported Could not setup wp-cli, then the initial wp core download exited 127 with wp: command not found, before the modified implementation ran.
Could a maintainer rerun only those failed jobs? The targeted gh run rerun 38125458556 --failed attempt was denied with Must have admin rights to Repository. The logs do not indicate a code correction for this patch.
Added two params:
We still have to miss (based on wp_insert_post()) those fields:
But I'm not sure we should add it.
#WCPL2017