Magento 2:如何在尝试序列化结帐配置时查找导致错误 "Malformed UTF-8 characters, possibly incorrectly encoded" 的配置
Magento 2: How to find which config causing error "Malformed UTF-8 characters, possibly incorrectly encoded" when trying to serialize checkout config
我正在使用 Magneto 2.3.4。在 vendor/magento/module-checkout/view/frontend/templates/onepage.phtml
中有这样一行:
window.checkoutConfig = <?= /* @noEscape */ $block->getSerializedCheckoutConfig() ?>;
按照函数,归结为vendor/magento/module-checkout/Block/Onepage.php::getSerializedCheckoutConfig()
而序列化函数在vendor/magento/framework/Serialize/Serializer/JsonHexTag.php
我在异常信息中添加了json_last_error_msg()
,现在基本上错误信息是:
Exception #0 (InvalidArgumentException):
Unable to serialize value. Error:Malformed UTF-8 characters, possibly incorrectly encoded
如何快速找到具有格式错误的 UTF-8 字符的结帐配置值或密钥?或者如何在数据库中快速解决这个问题?
感谢 Magento StackExchange 上的建议,我能够调试并找到有问题的字符。
基本上使用 XDebug 调试正在使用 utf8 检查处理的键和值:
mb_detect_encoding($suspiciousString, 'UTF-8', true)
事实证明我使用的是错误的加密密钥,它将一些凭据解密为格式错误的字符
我正在使用 Magneto 2.3.4。在 vendor/magento/module-checkout/view/frontend/templates/onepage.phtml
中有这样一行:
window.checkoutConfig = <?= /* @noEscape */ $block->getSerializedCheckoutConfig() ?>;
按照函数,归结为vendor/magento/module-checkout/Block/Onepage.php::getSerializedCheckoutConfig()
而序列化函数在vendor/magento/framework/Serialize/Serializer/JsonHexTag.php
我在异常信息中添加了json_last_error_msg()
,现在基本上错误信息是:
Exception #0 (InvalidArgumentException):
Unable to serialize value. Error:Malformed UTF-8 characters, possibly incorrectly encoded
如何快速找到具有格式错误的 UTF-8 字符的结帐配置值或密钥?或者如何在数据库中快速解决这个问题?
感谢 Magento StackExchange 上的建议,我能够调试并找到有问题的字符。
基本上使用 XDebug 调试正在使用 utf8 检查处理的键和值:
mb_detect_encoding($suspiciousString, 'UTF-8', true)
事实证明我使用的是错误的加密密钥,它将一些凭据解密为格式错误的字符