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

Fix a bug in query builder where tables are sorted randomly #10942

Merged
merged 3 commits into from Dec 2, 2016

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Dec 2, 2016

When we sort tables for join we should never "return 0" because "0" means the sort order for tables will be different depending on the PHP version (PHP5 sorting vs PHP7 sorting). I have noticed a bug where it did sort the tables completely different on PHP5 vs PHP7 and then the query crashed because wrong tables were used first.

@tsteur tsteur added the Needs Review PRs that need a code review label Dec 2, 2016
@tsteur tsteur added this to the 3.0.0-b4 milestone Dec 2, 2016

if ($tA === $tB) {
return 1; // if both join same table keep order
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe even better would be to look up the index in the array that is being sorted and simply always keep the order but this would mean we need to use a closure when sorting with function ($tA, $tB) use ($tablesToBeSorted) . Could do it but would mean a little refactoring

{
$actionType = 3;
$idSite = 1;
$select = 'log_link_visit_action.custom_dimension_1,
Copy link
Member Author

Choose a reason for hiding this comment

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

I had a similar case where it resulted in errors when executing the query depending on the PHP version

@mattab
Copy link
Member

mattab commented Dec 2, 2016

Glad we found this bug now rather than later 😆

@mattab mattab merged commit 59ba07c into 3.x-dev Dec 2, 2016
@mattab mattab deleted the querybuilderfix branch December 2, 2016 04:30
@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Dec 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants