Type Error occurred when creating object: Magento\Framework\Locale\Resolver
when I run this command this error shows. I am using third party theme.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityType Error occurred when creating object: Magento\Framework\Locale\Resolver
when I run this command this error shows. I am using third party theme.
The fix for the issue -
Type Error occurred when creating the object: Magento\Framework\Locale\Resolver
is not modifying the core class at all. We need to understand the cause of it first. Modifying the core class is not recommended at all. The issue is not with the class vendor/magento/framework/Encryption/Adapter/SodiumChachaIetf.php
⚠️ But the issue with the crypt key added to your app/etc/env.php
The reason for this issue is the crypt key is mismatched. You must have taken the database dump from any other instance and trying to run with your current instance. So along with the database, you need to get the crypt key from the same setup where from you got the DB dump.
Just update the crypt key in env.php and it will work fine.
The fix is to use the same pair of crypt keys of the installation from where DB is being used.
Hope it is explained.
Mark me up if was helpful. Happy coding..!!
I have searched around and found this solution this is because of return $plainText
SodiumChachaIetf::decrypt() must be of the type string, boolean
Go to this file:
vendor/magento/framework/Encryption/Adapter/SodiumChachaIetf.php
And Update Below Code:
$plainText = sodium_crypto_aead_chacha20poly1305_ietf_decrypt(
$payload,
$nonce,
$nonce,
$this->key
);
if ($plainText == false)
{
return "";
}
return $plainText;
Can you check that you are using the proper crypt key for the database used? Magento's Encryption process will not work if the crypt used for encryption in the database is different than the one declared in the env.php file.
If you have no idea where to get the proper crypt file, you may copy the crypt hash from the magento instance that dumped the database that you are using.
Clear your cache afterwards by deleting them manually.
Different key to what was in place when you installed site against what's now in place will cause this issue
Once lost no way to get back
Will only affect handful of extensions that rely on reversible encryption
Magento solution is this
I had the same issue and I solved it by adding a typecase when returning the variable.
File: vendor/magento/framework/Encryption/Adapter/SodiumChachaIetf.php
/**
* Decrypt a string
*
* @param string $data
* @return string
*/
public function decrypt(string $data): string
{
$nonce = mb_substr($data, 0, SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES, '8bit');
$payload = mb_substr($data, SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES, null, '8bit');
$plainText = sodium_crypto_aead_chacha20poly1305_ietf_decrypt(
$payload,
$nonce,
$nonce,
$this->key
);
return (string) $plainText; // <- Add the typecase (string) before the variable
}