Skip to content

Conversation

dennisvanderweide
Copy link

@dennisvanderweide dennisvanderweide commented Sep 18, 2023

Description (*)

The wrong variable is being checked for null, which can cause a null reference exception in the bulk source transfer

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

The wrong variable is being checked for null, which can cause a null reference exception
@engcom-Hotel
Copy link
Collaborator

@magento run all tests


if ($orgSourceItem !== null) {
$status = (int) $orgSourceItem[SourceItemInterface::STATUS];
} elseif ($dstSourceItemQty !== null) {
Copy link
Collaborator

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

Copy link
Author

@dennisvanderweide dennisvanderweide Sep 25, 2025

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@engcom-Hotel engcom-Hotel left a 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.

@dennisvanderweide
Copy link
Author

@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.

@engcom-Hotel
Copy link
Collaborator

✔️ 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.

@engcom-Hotel
Copy link
Collaborator

@magento run all tests

@engcom-Hotel engcom-Hotel moved this from Reviewer Approved to Ready for Delivery in Inventory - Pull Request Progress Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Ready for Delivery

Development

Successfully merging this pull request may close these issues.

2 participants