-
Notifications
You must be signed in to change notification settings - Fork 254
Check correct variable for null #3398
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
base: develop
Are you sure you want to change the base?
Conversation
The wrong variable is being checked for null, which can cause a null reference exception
df25e96
to
d892fff
Compare
@magento run all tests |
|
||
if ($orgSourceItem !== null) { | ||
$status = (int) $orgSourceItem[SourceItemInterface::STATUS]; | ||
} elseif ($dstSourceItemQty !== null) { |
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.
Hello @dennisvanderweide,
Thank you for your contribution!
Please let us know in which scenario the existing will create an issue.
Also please help us with the manual testing scenario.
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.
@engcom-Hotel In case $dstSourceItem
is null
, $dstSourceItemQty
will be 0.0
(line 124). If $orgSourceItem
is also null
it will trigger this if statement. $dstSourceItemQty !== null
will be false, because it will be 0.0
, but dstSourceItem
is still null
. $dstSourceItem[SourceItemInterface::STATUS]
then gives an error.
I don't know how $orgSourceItem
and $dstSourceItem
can be both null
, both this happend with one of our customers and I saw that this if statement doesn't handle this correctly.
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.
Make sense to me thank you for the clarification.
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.
Approving this PR.
@dennisvanderweide requesting you to provide some manual testing scenario to test the functionality.
@engcom-Hotel Well, it's almost a year ago that I created this PR, so I don't really remember what our customer did to have this issue. |
✔️ QA Passed No manual testing scenario required. The PR's purpose is to correct a logical error in variable checking that causes the system to crash when attempting to read the status property from a null source item object. It's a simple but critical fix that ensures proper null validation before array access, preventing fatal errors during bulk inventory transfer operations. Hence moving it further for merging. |
@magento run all tests |
Description (*)
The wrong variable is being checked for null, which can cause a null reference exception in the bulk source transfer
Contribution checklist (*)