-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Github #31984: fix for array offset bug during some 404s (PHP 7.4) #31985
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
Github #31984: fix for array offset bug during some 404s (PHP 7.4) #31985
Conversation
Hi @erfanimani. 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 |
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 @erfanimani,
Could you cover your changes with any type of automated tests?
@ihor-sviziev I'm thinking it might be hard to isolate this particular issue as it's nested within a few private method calls, but I'll have a look tomorrow — thanks for the feedback |
Hi @ihor-sviziev, I can't create unit tests as the SUT contains only private/protected methods. I can create a MFTF test that reproduces the error (although sometimes it won't, depending on PHP error reporting and PHP version), and simply returns a 404 not found if successful. I'm not sure how relevant a test like that would be for the future. What's your opinion? See the original issue for steps to reproduce. |
I don’t think mftf test sis suitable here. |
@ihor-sviziev I think can try via unit test by using reflection. |
@erfanimani @engcom-Charlie |
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 @erfanimani,
Could you cover your changes with the unit test, as suggested in #31985 (comment) ?
Thanks @ihor-sviziev, I'll try and update the PR. |
b95f3ff
to
6316620
Compare
@ihor-sviziev, please see the updated PR. I believe I've got 100% test coverage of the method that was changed. Feedback is appreciated. Thanks. |
Hi @erfanimani, thank you for your contribution! |
/** | ||
* @var UrlRewriteFactory|MockObject | ||
*/ | ||
private $urlRewriteFactory; |
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.
Please add "Mock" suffix to all mocks
private $urlRewriteFactory; | |
private $urlRewriteFactoryMock; |
public function testFindProductRewriteByRequestPath( | ||
$data, | ||
$productFromDb, | ||
$categorySuffix, | ||
$categoryFromDb, | ||
$canBeShownInCategory, | ||
$expectedProductRewrite | ||
) { |
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.
Let's define object types
public function testFindProductRewriteByRequestPath( | |
$data, | |
$productFromDb, | |
$categorySuffix, | |
$categoryFromDb, | |
$canBeShownInCategory, | |
$expectedProductRewrite | |
) { | |
public function testFindProductRewriteByRequestPath( | |
array $data, | |
$productFromDb, | |
string? $categorySuffix, | |
$categoryFromDb, | |
bool $canBeShownInCategory, | |
array? $expectedProductRewrite | |
): void { |
* @param $data | ||
* @param $productFromDb | ||
* @param $categorySuffix | ||
* @param $categoryFromDb | ||
* @param $canBeShownInCategory | ||
* @param $expectedProductRewrite |
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.
please define expected types for params
Thanks for the feedback @ihor-sviziev, I've updated the PR with your suggestions. |
@magento run all tests |
@magento run Integration Tests |
Hi @ihor-sviziev, thank you for the review. |
Hi @erfanimani, thank you for your contribution! |
Description (*)
Fixes "Trying to access array offset on value of type bool" when accessing certain non existing category paths for known products, on PHP 7.4.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)