-
Notifications
You must be signed in to change notification settings - Fork 56
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
checkout: unserialize() Exception #134
Comments
At first I thought this was a bug. But I can't really reproduce it in a freshly installed Mage 2.1.7, mainly because I can't find the "Show all articles" link you described. As a background, why we introduced this change: Mage 2.2 doesn't allow serialized values anymore and prefers json, while we used serialized values in our plugin prior to Mage 2.2 compatibility. However, I'm not quite sure why our module is getting active in the stage you're describing. Do you maybe have a complete stacktrace? |
Sorry, with "Show all articles" i mean checkout/cart. I sent you a complete stacktrace in a private mail (me@fbender.de) Thank you |
I have that issue too. A fresh completely untouched installation of Payone 2.0.2 (dc9ff4e) on Magento 2.1.10, PHP 7.0. Added an article to the cart and called The stack trace is as follows:
Tracing with xdebug led me to some more information: the full value in That renders the Payone extension unusable, I have no idea how to fix or work-around that. |
@nixn As a workaround you can patch /**
* Handle the serialization of strings depending on the Magento version
*
* @param mixed $mValue
* @return string
*/
public function serialize($mValue) {
return json_encode($mValue);
}
/**
* @param string $sValue
* @return mixed
*/
public function unserialize($sValue) {
return json_decode($sValue, true);
} This is not ideal and we'll take a look why the data is stored in json in the database the first place. |
Thanks for your hint, I've written a plugin to override these two methods: <?php
namespace Vendor\Module\Plugin;
use Payone\Core\Helper\Base;
class HelperBase
{
public function aroundSerialize(Base $subject, callable $proceed, $mValue)
{
return json_encode($mValue);
}
public function aroundUnserialize(Base $subject, callable $proceed, $sValue)
{
if (preg_match('/^[a-z][:;]/i', $sValue))
return unserialize($sValue);
return json_decode($sValue, true);
}
} I'm using this plugin for
|
Can any of you confirm that #144 fixes this issue? Basically, we don't really care anymore whether the objects were saved with |
Magento 2.1.7
PHP 5.6
Then:
1 exception(s):
Exception #0 (Exception): Notice: unserialize(): Error at offset 0 of 751 bytes in /xxx/xxx/xxx/vendor/payone-gmbh/magento-2/Helper/Base.php on line 139
Exception #0 (Exception): Notice: unserialize(): Error at offset 0 of 751 bytes in /xxx/xxx/xxx/vendor/payone-gmbh/magento-2/Helper/Base.php on line 139
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(8, 'unserialize(): ...', '/xxx/xxx/xxx/...', 139, Array)
#1 /xxx/xxx/xxx/vendor/payone-gmbh/magento-2/Helper/Base.php(139): unserialize('{"Number_type":...')
This is the original function unserialize():
The Problem i think is, you are expecting here that all Magento2 versions under 2.2.0 do not deal here with json objects. But the version i am using can not deal with the returned serialized version because it is expecting here a json object.
i updated the if condition
if (version_compare($this->shopHelper->getMagentoVersion(), '2.2.0', '>='))
to
(version_compare($this->shopHelper->getMagentoVersion(), '2.1.7', '>='))
and it is works.
I have to see now, if i will get another errors because of the wrong version or wrong returned data type after i configurated Payone.
I am waiting for your feedback.
Regards.
The text was updated successfully, but these errors were encountered: