Closed wrongspot closed 1 month ago
with PHP 8 and Plugin Version 4.6.3 we notice these fatal error on Notification Action
2022/04/05 10:29:04 [error] 15898#15898: *68679 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: utf8_encode(): Argument #1 ($string) must be of type string, array given in /var/webroot/Plugins/Community/Frontend/MoptPaymentPayone/Controllers/Frontend/MoptShopNotification.php:88 Stack trace: #0 [internal function]: utf8_encode() #1 /var/webroot/Plugins/Community/Frontend/MoptPaymentPayone/Controllers/Frontend/MoptShopNotification.php(88): array_map() #2 /var/webroot/vendor/shopware/shopware/engine/Library/Enlight/Controller/Action.php(182): Shopware_Controllers_Frontend_MoptShopNotification->indexAction() #3 /var/webroot/vendor/shopware/shopware/engine/Library/Enlight/Controller/Dispatcher/Default.php(461): Enlight_Controller_Action->dispatch() #4 /var/webroot/vendor/shopware/shopware/engine/Library/Enlight/Controller/Front.php(225" while reading response header from upstream, client: 1.1.1.1, server: anonymized, request: "POST /de/de/MoptShopNotification HTTP/1.1", upstream: "fastcgi://unix:/var/lib/php5-fpm/web13.sock:", host: "anonymized"
I took a closer look. this error does not always occur, only when the shopping cart is transferred. At this Point https://github.com/PAYONE-GmbH/shopware-5/blob/master/Frontend/MoptPaymentPayone/Controllers/Frontend/MoptShopNotification.php#L87 Post Array looks like this:
array ( 'key' => 'anonymized', 'txaction' => 'appointed', 'mode' => 'live', 'portalid' => 'anonymized', 'aid' => 'anonymized', 'clearingtype' => 'wlt', 'txtime' => '1649165823', 'currency' => 'EUR', 'userid' => 'anonymized', 'param' => 'session-1|d57t8cftts7morkb4v3kjluae8|a224a05bdc2588eba7df3dc4dda88da6', 'firstname' => 'Max', 'lastname' => 'Mustermann', 'street' => 'Teststraße 12', 'zip' => '12345', 'city' => 'Berlin', 'country' => 'DE', 'shipping_firstname' => 'Max', 'shipping_lastname' => 'Mustermann', 'shipping_street' => 'Teststraße 12', 'shipping_zip' => '12345', 'shipping_city' => 'Berlin', 'shipping_country' => 'DE', 'email' => 'test@example.com', 'txid' => '654237856', 'reference' => 'mopt-624c467c7018a22', 'sequencenumber' => '0', 'price' => '42.90', 'receivable' => '42.90', 'balance' => '42.90', 'transaction_status' => 'completed', 'notify_version' => '7.6', 'clearingsubtype' => 'PPE', )
This is a this is a one-dimensional array. In case, you have option transmit order positions enabled, then your Array looks like this:
array ( 'key' => 'anonymized', 'txaction' => 'appointed', 'mode' => 'live', 'portalid' => 'anonymized', 'aid' => 'anonymized', 'clearingtype' => 'cc', 'txtime' => '1649068855', 'currency' => 'EUR', 'userid' => 'anonymized', 'param' => 'session-1|1puerac6fisqi9ure44mj9sif5|7051bb5ace726178343cc6f2162d6f5f', 'firstname' => 'Max', 'lastname' => 'Mustermann', 'street' => 'Teststraße 12', 'zip' => '12345', 'city' => 'Graz', 'country' => 'AT', 'shipping_firstname' => 'Max', 'shipping_lastname' => 'Mustermann', 'shipping_street' => 'Teststraße 12', 'shipping_zip' => '12345', 'shipping_city' => 'Graz', 'shipping_country' => 'AT', 'email' => 'test@example.com', 'txid' => '653678365', 'reference' => 'mopt-624acb3764c4c12', 'sequencenumber' => '0', 'price' => '56.08', 'receivable' => '56.08', 'balance' => '56.08', 'cardpan' => 'xxxxxxxxxxx', 'cardtype' => 'V', 'cardexpiredate' => 'xxxx', 'cardholder' => 'Some Random', 'it' => array ( 1 => 'goods', 2 => 'shipment', ), 'id' => array ( 1 => '133-MKLM', 2 => 'ship22', ), 'pr' => array ( 1 => '7.01', 2 => '0.00', ), 'no' => array ( 1 => '8', 2 => '1', ), 'de' => array ( 1 => 'Some Random 38/40', 2 => 'DHL International (AT)', ), 'va' => array ( 1 => '20.00', 2 => '0.00', ), 'transaction_status' => 'completed', 'notify_version' => '7.6', 'clearingsubtype' => 'V', )
The Problem is, this piece of code array_map('utf8_encode', $_POST); will only work for one-dimensional array. Whenever order items are transferred, there is a fatal error. And at this point, https://github.com/PAYONE-GmbH/shopware-5/blob/master/Frontend/MoptPaymentPayone/Controllers/Frontend/MoptShopNotification.php#L289 you try the same.
array_map('utf8_encode', $_POST);
Here is an failing example https://phpsandbox.io/e/x/lnr9m
with PHP 8 and Plugin Version 4.6.3 we notice these fatal error on Notification Action
I took a closer look. this error does not always occur, only when the shopping cart is transferred. At this Point https://github.com/PAYONE-GmbH/shopware-5/blob/master/Frontend/MoptPaymentPayone/Controllers/Frontend/MoptShopNotification.php#L87 Post Array looks like this:
This is a this is a one-dimensional array. In case, you have option transmit order positions enabled, then your Array looks like this:
The Problem is, this piece of code
array_map('utf8_encode', $_POST);
will only work for one-dimensional array. Whenever order items are transferred, there is a fatal error. And at this point, https://github.com/PAYONE-GmbH/shopware-5/blob/master/Frontend/MoptPaymentPayone/Controllers/Frontend/MoptShopNotification.php#L289 you try the same.Here is an failing example https://phpsandbox.io/e/x/lnr9m