Magento warning after updating to 2.3.2

After updating from Magento to 2.3.2 you might as well get the following PHP error:

Warning: Use of undefined constant SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13 – assumed ‘SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13’ (this will throw an Error in a future version of PHP) in /var/www/html/vendor/magento/framework/Encryption/Encryptor.php on line 153

After some quick searching on Google, the reason is found: Magento require libsodium due to some security enhancements.
Unfortunately this is not documented well.

Some checks showed that libsodium was already installed, but that installed version did not yet provide the constant which PHP is complaining about.
In my docker environment a newer version is not available out of the box, so I had to add it manually:

wget \
    && tar xfvz libsodium-1.0.18.tar.gz \
    && cd libsodium-1.0.18 \
    && ./configure \
    && make && make install \
    && pecl install -f libsodium

Now check if pecl added the sodium.ini to your PHP`s conf.d folder to enable the PHP module.

With the following command you can verify if the correct version was installed for libsodium headers + library:

php -i | grep "sodium"

The result should look like this:

sodium support => enabled
sodium compiled version => 2.0.20
libsodium headers version => 1.0.18
libsodium library version => 1.0.18

Now your Magento installation should work again!

4 thoughts on “Magento warning after updating to 2.3.2”

  1. I’ve tried the install, but get the following error:

    (uiserver):u97786752:~$ pecl install -f libsodium

    Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 92160 bytes) in /usr/lib/php4.4/PEAR/PackageFile/v2.php on line 1288

    I have master value for memory_limit set to 756MB, local value is set to -1, which removes restrictions.

    This is a Debian GNU/Linux environment.

    1. To me the path of the file is confusing. There it says “php4.4”.
      Could it be, that your PECL installation is using the wrong PHP binaries?

    1. Generally the php binaries are not included in that tarball.

      Please check in your console the result of which php. This should give you all
      your php binaries.

      For the pecl execution you should tell pecl which PHP version to use by add -d php_suffix=7.2 for example.
      So the full command looks like pecl -d php_suffix=7.2 install -f libsodium
      The php version should obviously exist.
      This approach is untested.
      If this does not work try to execute pecl right from the target php installation.
      For this you should locate the folder by which php and try to find the pecl folder (e.g. /usr/local/lib/php/5.6/pecl),
      instead of just use pecl in the install command, take that whole path.

Leave a Reply to schoerwerth Cancel reply

Your email address will not be published. Required fields are marked *