8

Type Error occurred when creating object: Magento\Framework\Locale\Resolver

when I run this command this error shows. I am using third party theme.

Already tried deleting generated and var/di enter image description here

asked Jun 13, 2019 at 10:29
11
  • check your system.log from var/log/system.log. Here you can find the issue Commented Jun 13, 2019 at 10:30
  • Deleting var/generation, var/cache and var/di and try Commented Jun 13, 2019 at 10:33
  • already done deleting now it stop even showing any error Commented Jun 13, 2019 at 10:34
  • run php bin/magento setup:static-content:deploy -f now it will generate again Commented Jun 13, 2019 at 10:35
  • nothing no result Commented Jun 13, 2019 at 10:37

5 Answers 5

17

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..!!

Rafael Corrêa Gomes
13.9k15 gold badges92 silver badges190 bronze badges
answered Sep 13, 2019 at 6:40
1
  • 1
    It works if you clear the value in env.php too. Thanks. Commented Jan 25, 2022 at 18:08
7

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;
answered Jun 13, 2019 at 11:38
0

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.

answered Jun 26, 2019 at 17:57
0

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

https://magento.stackexchange.com/a/278420/70343

answered Jun 26, 2019 at 21:52
0

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
}
answered Dec 20, 2019 at 8:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.