If sodium extension needs to be enabled, it should be required in composer.json

Created on 9 October 2022, almost 2 years ago
Updated 17 November 2023, 11 months ago

Problem/Motivation

I'm running Drupal 9.4 with PHP 8.1. I've been using this module locally and data appears to be encrypted even though I don't have the sodium extension enabled in PHP.

Is this actually a requirement? The module README links to https://github.com/jedisct1/libsodium, but from PHP 7 this is now bundled with PHP, right?

So I'm confused as to whether the extension needs to be enabled or not. If it does need to be enabled, the extension should be required in composer.json to warn the user that they don't yet meet the requirements.

🐛 Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

🇯🇵Japan ptmkenny

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇵🇪Peru marvil07

    So I'm confused as to whether the extension needs to be enabled or not. If it does need to be enabled, the extension should be required in composer.json to warn the user that they don't yet meet the requirements.

    Upon further investigation, it is required, so that requirement should be marked in the module's composer.json.

    Yes, it sounds like a good idea to add the extension dependency.
    Some reasoning below.

    The current composer version declares a dependency on php 7.2 and halite library.

      "require": {
        "php": ">=7.2",
        "drupal/key": "^1.0",
        "drupal/encrypt": "^3.0",
        "paragonie/halite": "^4.1 || ^5.0"
      }
    

    Then, halite declares on its composer file a dependency on paragonie/sodium_compat: ^1.17, which suggests ext-sodium for PHP 7.0+.
    And yes, that is a suggests and not a requires, which is likely to allow both pre and post php 7 versions to work, since the pre-php7 version is suggesting ext-libsodium instead, which made sense at the time.

    Said that, the sodium_requirements() implementation here and the composer file is requiring php 7.2+, so indeed ext-sodium is required.

    Hence, adding the requirement to composer makes sense.
    Marking as RTBC.

  • 🇯🇵Japan ptmkenny

    3.x is the target for new development.

  • 🇯🇵Japan ptmkenny

    Whoops, seems this is only applicable to 2.x.

  • 🇯🇵Japan ptmkenny

    Adding this will break the tests, and it only applies to installations that have unsupported versions of PHP, so I'll close this now.

Production build 0.71.5 2024