PAYONE-GmbH / magento-2

PAYONE Payment Extension for Magento 2
28 stars 56 forks source link

Cannot modify readonly property Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::$alternativeHeaders #544

Closed netzkollektiv closed 3 days ago

netzkollektiv commented 3 months ago

After upgrading to Magento 2.4.7 we experience the following issue as Magento introduced readonly properties for classes. Checkout with Payone is not possible.

[2024-06-20T09:18:34.613341+00:00] .CRITICAL: Error: Cannot modify readonly property Magento\Framework\HTTP\PhpEnvironment\RemoteAddress::$alternativeHeaders in /var/www/

html/web/vendor/payone-gmbh/magento-2/Model/Environment/RemoteAddress.php:44
Stack trace:
#0 /var/www/
html/web/vendor/payone-gmbh/magento-2/Helper/Environment.php(80): Payone\Core\Model\Environment\RemoteAddress->useHttpXForwarded()
#1 /var/www/
html/web/vendor/payone-gmbh/magento-2/Model/Api/Request/Authorization.php(159): Payone\Core\Helper\Environment->getRemoteIp()
#2 /var/www/
html/web/vendor/payone-gmbh/magento-2/Model/Api/Request/Authorization.php(111): Payone\Core\Model\Api\Request\Authorization->setAuthorizationParameters()
#3 /var/www/
html/web/vendor/payone-gmbh/magento-2/Model/Methods/PayoneMethod.php(144): Payone\Core\Model\Api\Request\Authorization->sendRequest()
#4 /var/www/
html/web/vendor/payone-gmbh/magento-2/Model/Methods/BaseMethod.php(300): Payone\Core\Model\Methods\PayoneMethod->sendPayoneAuthorization()
#5 /var/www/
html/web/vendor/magento/module-sales/Model/Order/Payment/Operations/AuthorizeOperation.php(45): Payone\Core\Model\Methods\BaseMethod->authorize()
#6 /var/www/
html/web/vendor/magento/module-sales/Model/Order/Payment/Processor.php(72): Magento\Sales\Model\Order\Payment\Operations\AuthorizeOperation->authorize()
#7 /var/www/
html/web/vendor/magento/module-sales/Model/Order/Payment.php(1136): Magento\Sales\Model\Order\Payment\Processor->authorize()
#8 /var/www/
html/web/vendor/magento/module-sales/Model/Order/Payment.php(458): Magento\Sales\Model\Order\Payment->authorize()
#9 /var/www/
html/web/vendor/magento/module-sales/Model/Order/Payment.php(385): Magento\Sales\Model\Order\Payment->processAction()
#10 /var/www/
html/web/vendor/magento/module-sales/Model/Order.php(1052): Magento\Sales\Model\Order\Payment->place()
#11 /var/www/
html/web/vendor/magento/module-sales/Model/Order.php(1278): Magento\Sales\Model\Order->_placePayment()
#12 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Sales\Model\Order->place()
#13 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Sales\Model\Order\Interceptor->___callParent()
#14 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Sales\Model\Order\Interceptor->Magento\Framework\Interception\{closure}()
#15 /var/www/
html/web/generated/code/Magento/Sales/Model/Order/Interceptor.php(32): Magento\Sales\Model\Order\Interceptor->___callPlugins()
#16 /var/www/
html/web/vendor/magento/module-sales/Model/Service/OrderService.php(245): Magento\Sales\Model\Order\Interceptor->place()
#17 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Sales\Model\Service\OrderService->place()
#18 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Sales\Model\Service\OrderService\Interceptor->___callParent()
#19 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Sales\Model\Service\OrderService\Interceptor->Magento\Framework\Interception\{closure}()
#20 /var/www/
html/web/generated/code/Magento/Sales/Model/Service/OrderService/Interceptor.php(32): Magento\Sales\Model\Service\OrderService\Interceptor->___callPlugins()
#21 /var/www/
html/web/vendor/magento/module-quote/Model/QuoteManagement.php(624): Magento\Sales\Model\Service\OrderService\Interceptor->place()
#22 /var/www/
html/web/vendor/magento/module-quote/Model/QuoteManagement.php(501): Magento\Quote\Model\QuoteManagement->submitQuote()
#23 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Quote\Model\QuoteManagement->submit()
#24 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Quote\Model\QuoteManagement\Interceptor->___callParent()
#25 /var/www/
html/web/vendor/magento/module-sales-rule/Plugin/CouponUsagesIncrement.php(54): Magento\Quote\Model\QuoteManagement\Interceptor->Magento\Framework\Interception\{closure}()
#26 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(135): Magento\SalesRule\Plugin\CouponUsagesIncrement->aroundSubmit()
#27 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Quote\Model\QuoteManagement\Interceptor->Magento\Framework\Interception\{closure}()
#28 /var/www/
html/web/generated/code/Magento/Quote/Model/QuoteManagement/Interceptor.php(32): Magento\Quote\Model\QuoteManagement\Interceptor->___callPlugins()
#29 /var/www/
html/web/vendor/magento/module-quote/Model/QuoteManagement.php(459): Magento\Quote\Model\QuoteManagement\Interceptor->submit()
#30 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Quote\Model\QuoteManagement->placeOrder()
#31 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Quote\Model\QuoteManagement\Interceptor->___callParent()
#32 /var/www/
html/web/vendor/paypal/module-braintree-core/Plugin/OrderCancellation.php(64): Magento\Quote\Model\QuoteManagement\Interceptor->Magento\Framework\Interception\{closure}()
#33 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(135): PayPal\Braintree\Plugin\OrderCancellation->aroundPlaceOrder()
#34 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Quote\Model\QuoteManagement\Interceptor->Magento\Framework\Interception\{closure}()
#35 /var/www/
html/web/generated/code/Magento/Quote/Model/QuoteManagement/Interceptor.php(23): Magento\Quote\Model\QuoteManagement\Interceptor->___callPlugins()
#36 /var/www/
html/web/vendor/magento/module-quote/Model/GuestCart/GuestCartManagement.php(87): Magento\Quote\Model\QuoteManagement\Interceptor->placeOrder()
#37 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Quote\Model\GuestCart\GuestCartManagement->placeOrder()
#38 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Quote\Model\GuestCart\GuestCartManagement\Interceptor->___callParent()
#39 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Quote\Model\GuestCart\GuestCartManagement\Interceptor->Magento\Framework\Interception\{closure}()
#40 /var/www/
html/web/generated/code/Magento/Quote/Model/GuestCart/GuestCartManagement/Interceptor.php(32): Magento\Quote\Model\GuestCart\GuestCartManagement\Interceptor->___callPlugins()
#41 /var/www/
html/web/vendor/magento/module-checkout/Model/GuestPaymentInformationManagement.php(142): Magento\Quote\Model\GuestCart\GuestCartManagement\Interceptor->placeOrder()
#42 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Checkout\Model\GuestPaymentInformationManagement->savePaymentInformationAndPlaceOrder()
#43 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->___callParent()
#44 /var/www/
html/web/vendor/teambank/ratenkaufbyeasycredit-plugin-magento-2/Plugin/InterceptGuestSaveOrder.php(33): Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->Magento\Framework\Interception\{closure}()
#45 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(135): Netzkollektiv\EasyCredit\Plugin\InterceptGuestSaveOrder->aroundSavePaymentInformationAndPlaceOrder()
#46 /var/www/
html/web/vendor/payone-gmbh/magento-2/Model/Plugins/GuestPaymentInformationManagement.php(100): Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->Magento\Framework\Interception\{closure}()
#47 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(135): Payone\Core\Model\Plugins\GuestPaymentInformationManagement->aroundSavePaymentInformationAndPlaceOrder()
#48 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->Magento\Framework\Interception\{closure}()
#49 /var/www/
html/web/generated/code/Magento/Checkout/Model/GuestPaymentInformationManagement/Interceptor.php(23): Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->___callPlugins()
#50 [internal function]: Magento\Checkout\Model\GuestPaymentInformationManagement\Interceptor->savePaymentInformationAndPlaceOrder()
#51 /var/www/
html/web/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array()
#52 /var/www/
html/web/vendor/magento/module-webapi/Controller/Rest.php(201): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process()
#53 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch()
#54 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent()
#55 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}()
#56 /var/www/
html/web/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(23): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins()
#57 /var/www/
html/web/vendor/magento/framework/App/Http.php(116): Magento\Webapi\Controller\Rest\Interceptor->dispatch()
#58 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch()
#59 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->___callParent()
#60 /var/www/
html/web/vendor/magento/module-application-performance-monitor/Plugin/ApplicationPerformanceMonitor.php(38): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#61 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(135): Magento\ApplicationPerformanceMonitor\Plugin\ApplicationPerformanceMonitor->aroundLaunch()
#62 /var/www/
html/web/vendor/justbetter/magento2-sentry/Plugin/GlobalExceptionCatcher.php(69): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#63 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(135): JustBetter\Sentry\Plugin\GlobalExceptionCatcher->aroundLaunch()
#64 /var/www/
html/web/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#65 /var/www/
html/web/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->___callPlugins()
#66 /var/www/
html/web/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
#67 /var/www/
html/web/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#68 {main} {"exception":"[object] (Error(code: 0): Cannot modify readonly property Magento\\Framework\\HTTP\\PhpEnvironment\\RemoteAddress::$alternativeHeaders at /var/www/
html/web/vendor/payone-gmbh/magento-2/Model/Environment/RemoteAddress.php:44)"} []
hummer2k commented 3 months ago

Workaround: Prepopulate the $alternativeHeaders via di.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Payone\Core\Model\Environment\RemoteAddress">
        <arguments>
            <argument name="alternativeHeaders" xsi:type="array">
                <item name="x-forwarded-for" xsi:type="string">HTTP_X_FORWARDED_FOR</item>
            </argument>
        </arguments>
    </type>
</config>
janteuber commented 3 months ago

Hello @netzkollektiv @hummer2k

Thank you very much for your messages.

We are currently working on a new plugin version that will also be compatible with 2.4.7.

FatchipRobert commented 2 months ago

Problem is fixed in #545