-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fix SQL error throwed when websiteId is NULL #36802
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 SQL error throwed when websiteId is NULL #36802
Conversation
Hi @Sekiphp. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review. For more details, 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, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Magento Health Index |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
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 @Sekiphp,
Your changes looks good. Could you please cover your change with some automated tests?
@@ -332,13 +332,9 @@ public function addWebsiteGroupDateFilter($websiteId, $customerGroupId, $now = n | |||
'customer_group_ids.' . | |||
$entityInfo['entity_id_field'] . | |||
' = cgw.' . | |||
$entityInfo['entity_id_field'] . ' AND ' . $websiteId . ' = cgw.website_id', | |||
$entityInfo['entity_id_field'] . ' AND ' . (int) $websiteId . ' = cgw.website_id', |
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.
In my opinion there is not solving core of issue because it's looks like unpredictable application behavior.
Everywhere we expect to receive integer value of website id and we need to solve core of this problem specifically why website id is null.
@Sekiphp could you please add total list of steps for reproducing the error
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.
@Den4ik It is truth. I was not able to simulate this error, but this part is problematic and I just use same solution, which is used in method, which is also called inside this method. In our website there are a lot of diferrent salesrules and probably not all are configured well and throws this error in some combination of steps.
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 @Sekiphp,
I just analyzed where this code is used - looks like it might be only in
foreach ($this->rssModel->getDiscountCollection($websiteId, $customerGroupId) as $rule) { |
While website id is getting retrieved from store. In case when store doesn't have linked website - this will trigger such error.
$websiteId = $storeModel->getWebsiteId(); |
In this case, I think direct type conversion is good
@magento run Integration Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento create issue |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@engcom-Charlie any updates on this? |
Hello @engcom-Lima @Sekiphp @Den4ik @ihor-sviziev |
@magento run all tests |
Hi @Sekiphp, Thank you for your contribution! Code wise the changes looks okay but we want to reproduce the issue in order to proceed further on the same. In magento its not possible to have a store without a websiteId attached to it. We tried to reproduce this issue on local setup with different sections and tried to see when addWebsiteGroupDateFilter is getting used but no luck. Can you please provide some more details on issue reproduction steps, till then moving this PR to On hold. Thank you! |
As mentioned here, we are unable to reproduce this issue hence closing this PR now. Please feel free to reopen it for any further updates. Thank you! |
Description (*)
In code is sometimes situation when
$websiteId
passed toaddWebsiteGroupDateFilter
is NULL.Throwed error in GraphQL
Code
Problematic part:

Inside

addWebsiteGroupDateFilter
is called$this->addWebsiteFilter($websiteId);
, butNULL
for$websiteId
is not problem there, because inside this method is this variable casted toint
.Manual testing scenarios (*)
Contribution checklist (*)
Resolved issues: