-
Notifications
You must be signed in to change notification settings - Fork 3k
[41604] Modified update_item() to read only POST body parameters thereby handling global query parameters #8975
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
[41604] Modified update_item() to read only POST body parameters thereby handling global query parameters #8975
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. |
$options = $this->get_registered_options(); | ||
|
||
$params = $request->get_params(); | ||
$query_params = $request->get_query_params(); | ||
$params = array_diff_key( $params, $query_params ); |
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.
Nit: I think we need to align the equals to avoid PHPCS warning errors:
public function update_item( $request ) {
$options = $this->get_registered_options();
$params = $request->get_params();
$query_params = $request->get_query_params();
$params = array_diff_key( $params, $query_params );
I don't know why it passed CI, but it gives a warning locally.
composer lint src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php
> @php ./vendor/squizlabs/php_codesniffer/bin/phpcs --report=summary,source 'src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php'
W 1 / 1 (100%)
PHP CODE SNIFFER REPORT SUMMARY
---------------------------------------------------------------------------------------------
FILE ERRORS WARNINGS
---------------------------------------------------------------------------------------------
src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php 0 3
---------------------------------------------------------------------------------------------
A TOTAL OF 0 ERRORS AND 3 WARNINGS WERE FOUND IN 1 FILE
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX 3 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------
Time: 61ms; Memory: 8MB
PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
-----------------------------------------------------------------------
SOURCE COUNT
-----------------------------------------------------------------------
[x] Generic.Formatting.MultipleStatementAlignment.NotSameWarning 3
-----------------------------------------------------------------------
A TOTAL OF 3 SNIFF VIOLATIONS WERE FOUND IN 1 SOURCE
-----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SOURCES AUTOMATICALLY (3 VIOLATIONS IN TOTAL)
-----------------------------------------------------------------------
Script @php ./vendor/squizlabs/php_codesniffer/bin/phpcs --report=summary,source handling the lint event returned with error code 2
Trac ticket: https://core.trac.wordpress.org/ticket/41604
This PR fixes the issue pointed out by @Mamaduka i.e., the API can contain global query parameters, such as _locale, which fail to pass. This is fixed by replacing the $request->get_params(); by $request->get_body_params()