#46302 closed enhancement (fixed)
Function clarity; Rename wp_get_user_request_data to wp_get_user_request as it returns the WP_User_Request
Reported by: | garrett-eclipse | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.4 | Priority: | normal |
Severity: | normal | Version: | 4.9.6 |
Component: | Privacy | Keywords: | has-patch needs-testing has-dev-note |
Focuses: | administration | Cc: |
Description
This is a follow-up to #44708.
In 5.1 changeset 44606 renamed variables from $request_data to $request. After a quick scrub it seems some were overlooked or are new.
Instances;
3 occurrences in the wp_create_user_request function - https://github.com/WordPress/WordPress/blob/50ddffbac37fdae9298d1f11fe1dd7b8535fc839/wp-includes/user.php#L3309-L3347
2 occurrences in the WP_User_Request class - https://github.com/WordPress/WordPress/blob/50ddffbac37fdae9298d1f11fe1dd7b8535fc839/wp-includes/user.php#L3712-L3738
I'm unsure if the instances in the class should be changed or not as the other changes were because the variable was held the entire class while this instance is a property of that class.
And a last thought was should the wp_get_user_request_data
not be wp_get_user_request
and it's docblock state 'Return the user request.' simply because it's a function to get the request itself and not just the request_data.
The function I mentioned - https://github.com/WordPress/WordPress/blob/50ddffbac37fdae9298d1f11fe1dd7b8535fc839/wp-includes/user.php#L3617-L3634
Thanks
Attachments (1)
Change History (9)
#1
@
5 years ago
- Component changed from Administration to Privacy
- Focuses administration added; privacy removed
- Keywords has-patch needs-testing needs-dev-note added
- Milestone changed from Awaiting Review to 5.4
- Version set to 4.9.6
Coming back to review the instances of $request_data I'd initially flagged were valid as they represented the array form of request data. The wp_get_user_request_data
function on the other hand specifically returns the WP_User_Request object which in itself has a $request_data property. To avoid confusion with this I've uploaded an initial patch to update the function to wp_get_user_request
in order to clarify it's purpose. To maintain back-compat I've deprecated the function.
Please review and test, so far beyond throwing the deprecation warning with use of the old function there's no change to the request functionality.
Flagging for testing and dev-note.
#2
@
5 years ago
- Summary changed from Coding consistency, found more $request_data that should be $request to Function clarity; Rename wp_get_user_request_data to wp_get_user_request as it returns the WP_User_Request
#3
@
5 years ago
Note... ignore the mismatch of patch number to ticket number. It's the right patch I just saved it as the wrong number.
This ticket was mentioned in Slack in #core by david.baumwald. View the logs.
5 years ago
#5
@
5 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 47245:
#7
@
5 years ago
I believe this was erroneously deprecated into:
/wp-admin/includes/deprecated.php
instead of:
/wp-includes/deprecated.php
.
Both the original function and the new one are available outside of WordPress admin, but the deprecated function is now only available within WordPress admin, which is a back-compat break.
See: https://buddypress.trac.wordpress.org/ticket/8265
@SergeyBiryukov Reopen, or create a new issue for 5.4.1?
Initial patch to correct the
wp_get_user_request_data
function as it returns the request and not the request_data which is a property of the WP_User_Request