mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
101 stars 53 forks source link

Call to a member function getStoreId() on null - Model/Methods/Voucher.php:107 #369

Closed hostep closed 3 years ago

hostep commented 3 years ago

Describe the bug I'm finding a bunch of PHP fatal errors in the apache error log. At first sight they seem to get triggered by a third party plugin, but I still believe there is a small bug in this module itself. Error:

[Mon Mar 15 13:02:48.920509 2021] [proxy_fcgi:error] [pid 91855:tid 139717512967936] [client 127.0.0.1:53824] AH01071:
Got error 'PHP message: PHP Fatal error:  Uncaught Error: Call to a member function getStoreId() on null in vendor/mollie/magento2/Model/Methods/Voucher.php:107
Stack trace:
#0 generated/code/Mollie/Payment/Model/Methods/Voucher/Interceptor.php(24): Mollie\\Payment\\Model\\Methods\\Voucher->isAvailable(NULL)
#1 vendor/magento/module-payment/Helper/Data.php(144): Mollie\\Payment\\Model\\Methods\\Voucher\\Interceptor->isAvailable(NULL)
#2 app/code/Magestore/Webpos/Model/Source/Adminhtml/Payment.php(146): Magento\\Payment\\Helper\\Data->getStoreMethods()
#3 app/code/Magestore/Webpos/Model/Payment/PaymentRepository.php(64): Magestore\\Webpos\\Model\\Source\\Adminhtml\\Payment->getPosPaymentMethods()
#4 [internal function]: Magestore\\Webpos\\Model\\Payment\\PaymentRepository-...
', referer: https://www.some-domain-name.be/nl/webpos

Used versions

To Reproduce Steps to reproduce the behavior:

  1. Look at the code over here
  2. The code seems to expect that $quote can be null (default value)
  3. However, it does use $quote->getStoreId() without checking if $quote is not null

Expected behavior Fewer errors in the log files

Actual behavior Errors in the log file

Screenshots

Additional context Issue seems to be accidentally created while refactoring this code in https://github.com/mollie/magento2/commit/c61b86535ad3c9c275ec74b2d8cfcc61b580d5ec#diff-0fd68464f7123a24cb46dccf285cf7039dc3f306fa7b8faa89d8d978b8dd6cebL29

Marvin-Magmodules commented 3 years ago

Hi @hostep, thank you for the detailed issue report. The additional context supplied seems logical and this issue wil be fixed in the next release.

Frank-Magmodules commented 3 years ago

HI @hostep

We are happy to share that we've just released the new 1.24.0 version with a fix for this issue. Thank you again for the detailed issue report. We are closing this issue now but please feel free to reopen the issue if this still occurs.