-
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
MC-23881: When category URL page param is larger than the pagination, the page will break with elastic search 2 #31594
Conversation
Hi @engcom-Golf. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
$searchQuery = [ | ||
'index' => $this->searchIndexNameResolver->getIndexName($storeId, $request->getIndex()), | ||
'type' => $this->clientConfig->getEntityType(), | ||
'body' => [ | ||
'from' => $request->getFrom(), | ||
'from' => $this->getFrom($request), |
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.
I think inline looks a bit cleaner. What do you thing?
'from' => $this->getFrom($request), | |
'from' => min((int)$request->getFrom(), self::ELASTIC_MAX_INT), |
PS What about negative values? Should we also handle it?
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.
Agree. Will update. But don't think that we need to handle negative values. In that case, elastic returns exception with message numHits must be > 0
@@ -61,7 +63,7 @@ public function initQuery(RequestInterface $request) | |||
'index' => $this->searchIndexNameResolver->getIndexName($storeId, $request->getIndex()), | |||
'type' => $this->clientConfig->getEntityType(), | |||
'body' => [ | |||
'from' => $request->getFrom(), | |||
'from' => $this->getFrom($request), |
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.
same here
@@ -23,6 +23,8 @@ | |||
*/ | |||
class Builder extends Elasticsearch5Builder | |||
{ | |||
private const ELASTIC_INT_MAX = 2147483647; |
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.
private const ELASTIC_INT_MAX = 2147483647; | |
private const ELASTIC_MAX_INT = 2147483647; |
@@ -22,6 +22,8 @@ | |||
*/ | |||
class Builder | |||
{ | |||
private const ELASTIC_INT_MAX = 2147483647; |
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.
private const ELASTIC_INT_MAX = 2147483647; | |
private const ELASTIC_MAX_INT = 2147483647; |
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.
Agree that max_int sounds better but there is defined PHP_INT_MAX constant. I think it is better to keep the same format here.
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.
Ok, that make sense
one more question - on elastic 5+ it works fine? |
… the page will break with elastic search 2
@ihor-sviziev fix tested for elastcsearch 6 and 7 versions |
@magento run all tests |
Hi @ihor-sviziev, thank you for the review. |
Note: Automation tests are passed |
@magento import code to https://github.com/magento-tsg/magento2ce |
@zakdma the branch with code successfully imported into |
Hi @engcom-Golf, thank you for your contribution! |
Description (*)
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Create a category with products
Enable elasticsearch
Reindex all
Go to the category and add this param: ?p=999999999999999
Expected result:
No out of range exception in logs with status 500
Note:
There still can be log entity with 400 status.
Redirect to the last page of the category is not expected.
Questions or comments
Contribution checklist (*)