-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
#26708 Fix: ORDER BY has two similar conditions in the SQL query #27263
#26708 Fix: ORDER BY has two similar conditions in the SQL query #27263
Conversation
Hi @vasilii-b. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
It seems to me related to #26934 |
@ihor-sviziev in my opinion isn't exactly the same, but I'd additionally check if this affects somehow the product listing with Elastic Search enabled. Moreover, I see that there are couple of failing tests related to ElasticSearch. |
5720637
to
1e1ebd3
Compare
Hi @eduard13, Thank you! |
…-sql-select-duplicated
@magento run all tests |
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.
The failing tests aren't related to these changes.
Thank you for your collaboration.
Hi @eduard13, thank you for the review. |
@@ -355,6 +355,7 @@ public function getIdentities() | |||
} | |||
|
|||
foreach ($this->_getProductCollection() as $item) { | |||
// phpcs:ignore Magento2.Performance.ForeachArrayMerge | |||
$identities = array_merge($identities, $item->getIdentities()); | |||
} |
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.
If possible not to use '// phpcs:ignore Magento2.Performance.ForeachArrayMerge'
$arraysItemsToMerge = []; foreach ($this->_getProductCollection() as $item) { $arraysItemsToMerge[] = $item->getIdentities(); } $identities = array_merge($identities, ...$arraysItemsToMerge);
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.
Hi @engcom-Echo,
Should we leave this part of the code as it was? We did not change it but because of this, there is a failed test. How we should proceed here? Any suggestions?
Thanks!
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.
Using 'array_merge' function in a 'for/foreach/while'.
It's a very bad practice because it's a performance killer (especially in memory).
I think if we can change it for the better, it will be very good.
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.
@engcom-Echo why should we change it in the scope of this PR if we didn't introduce it or modified it in the scope of this PR?
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.
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.
Hi @engcom-Echo, I have briefly checked, and looks like we aren't able replace it with anything. I was checking maybe we could use +
operator here, but it may bring some unexpected behavior.
The main reason, being that +
will remove the duplicated array values, in comparison with array_merge
which just pushes the new array at the end of another one.
So I'd suggest to proceed with another investigation (separately), of how and where exactly these identities are used, and see if we are able to remove the duplicated array values.
What do you think?
Thank you.
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.
So I'd suggest to proceed with another investigation (separately)....
Here I agree with you. Thanks for the discussion.
Failed functional tests not related to the changes in this PR |
Hi @vasilii-b, thank you for your contribution! |
Description (*)
The PR fixes two similar
order by
condition in the SQL query of theapp/code/Magento/Catalog/Block/Product/ListProduct.php
Related Pull Requests
#26754 - Original PR (the author gave up on the PR #26754 (comment))
#11473 - PR that introduced the issue
Fixed Issues (if relevant)
Manual testing scenarios (*)
Please see #26708
Questions or comments
@lenaorobei Could you please follow this PR, as you already did the review of the closed one #11473.
Contribution checklist (*)