Skip to content
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

Small refactor of parse_orderby to make it easier to read #3042

Merged
merged 2 commits into from
Oct 3, 2022

Conversation

felipeelia
Copy link
Member

@felipeelia felipeelia commented Oct 3, 2022

Description of the Change

This PR is just a small refactor of all Indexables' parse_orderby() method to change it from a stack of if-elses to something a bit more readable.

Closes #

How to test the Change

Changelog Entry

Changed - Small refactor of parse_orderby to make it easier to read

Credits

Props @felipeelia

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@felipeelia felipeelia added this to the 4.4.0 milestone Oct 3, 2022
$orderby_field = $orderby;
break;
if ( in_array( $orderby, [ 'meta_value', 'meta_value_num' ], true ) ) {
if ( empty( $args['meta_key'] ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check if $args['meta_key'] isset?

}

if ( in_array( $orderby_clause, [ 'meta_value', 'meta_value_num' ], true ) ) {
if ( empty( $args['meta_key'] ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before - validate isset $args['meta_key']

@felipeelia felipeelia merged commit 08209d7 into develop Oct 3, 2022
@felipeelia felipeelia deleted the chore/refactor-post-parse-orderby branch October 3, 2022 13:32
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.

2 participants