Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Simpler solution #47280#2829

Closed
spacedmonkey wants to merge 1 commit into
WordPress:trunkfrom
spacedmonkey:fix/55909
Closed

Simpler solution #47280#2829
spacedmonkey wants to merge 1 commit into
WordPress:trunkfrom
spacedmonkey:fix/55909

Conversation

@spacedmonkey

Copy link
Copy Markdown
Member

Trac ticket: https://core.trac.wordpress.org/ticket/47280


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.

@spacedmonkey spacedmonkey requested a review from johnbillion June 19, 2022 21:48
@spacedmonkey spacedmonkey self-assigned this Jun 19, 2022

@mukeshpanchal27 mukeshpanchal27 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The PR looks good to me. I have added some minor reviews on PR.

Comment on lines +994 to +995
{$this->sql_clauses['groupby']}
{$this->sql_clauses['orderby']}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For count value from the quer,y i don't think we need groupby and orderby. Is there any use case in which we need these clauses?

Comment on lines +512 to +513
{$this->sql_clauses['groupby']}
{$this->sql_clauses['orderby']}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please check above review comment

if ( ! $q['no_found_rows'] && ! empty( $limits ) ) {
$found_rows = 'SQL_CALC_FOUND_ROWS';
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is one empty line that needs to remove.

$found_request = "SELECT COUNT(*)
{$this->query_from}
{$this->query_where}
{$this->query_orderby}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Check my first review comment

Comment on lines +728 to +729
{$this->sql_clauses['groupby']}
{$this->sql_clauses['orderby']}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Check my first review comment.

Comment on lines +3134 to +3135
$groupby
$orderby

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Check my first review comment.

Comment on lines +3034 to +3035
$groupby
$orderby

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Check my first review comment.

@@ -728,7 +737,7 @@ private function set_found_sites() {
* @param string $found_sites_query SQL query. Default 'SELECT FOUND_ROWS()'.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs to update docblock regarding new update

@@ -826,7 +827,7 @@ public function query() {
* @param string $sql The SELECT FOUND_ROWS() query for the current WP_User_Query.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs to update docblock regarding new update

@MahdiAkrami01

MahdiAkrami01 commented Jul 20, 2022

Copy link
Copy Markdown

COUNT(*) query is not working when using GROUP BY in sql query .
and if you remove GROUP BYthe result is not the same as SELECT FOUND_ROWS()

see this exam. main query result has 415 rows but with count query if we remove GROUP BY we get 423 rows

image
image

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