Closed (fixed)
Project:
Real AES
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
4 Jul 2019 at 00:48 UTC
Updated:
7 Feb 2022 at 08:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jaypanPatch attached. Needs review. Note that I also updated the license identifier, as the one being used previously has been deprecated in favor of the one I changed it to. This can be confirmed by running
composer validate.Comment #3
rlhawkComment #5
rlhawkComment #6
jcnventuraI wonder why this was necessary. Drupal manages module dependency transparently via the composer packagist. The dependency on encrypt in .info.yml will add a composer dependency on the encrypt module. What this change did was to make explicit what the drupal.org packagist was doing implicitly. It's not bad, but it was also unnecessary, unless something escapes me here.
I think the best illustration why this was unnecessary is the fact that we've been using composer to install real_aes for 5 years now, and only now someone decided to create this issue.
Comment #7
jaypanNo it doesn't. This module declares a dependency on Real AES in the info file, but one was not declared in Composer. This meant that if you wanted Real AES, you would need to require both drupal/encrypt and drupal/real_aes. Without doing the first, the Real AES module cannot be enabled,
Composer should manage all dependencies. Therefore after requiring a package, you should not get an error about a missing package when trying to enable it. That means Composer is not managing the dependencies. This is what was happening before this patch. With this patch, Composer will now manage this module's dependencies.
That's not a logical argument. I clearly ran into a problem which is why I opened a ticket, and create a patch. Using your logic, I think the best illustration of why this was necessary is that I did it, and included reasoning in the original post.
Comment #8
gregglesThe issue summary here and the subsequent conversation is lacking a set of steps to repeat the problem and observe what might be fixed by making this change. Here's what I did to try to understand this situation and what I observed.
I started by creating a fresh drupal project:
composer create-project drupal/recommended-project my_site_name_dirThis got me a working directory which I added to a local git repo and committed so I could start from a known good state.
To see the behavior "before" this patch I required real aes 2.2:
composer require 'drupal/real_aes:^2.2'This seemed to install stuff just fine:
That seemed to find the dependency on "drupal/encrypt": "^3.0" even for an older version that did not have this patch in it. Three contribs were installed:
When I removed real_aes it seemed to detect some dependencies and remove them:
And after running that remove the contribs were all removed as were 3 items from vendor (generate-defuse-key, defuse, paragonie).
So, it seems from this research that installing a version of the module from drupal.org's composer facade is working as I expect it to, but I imagine there may be some scenarios where that doesn't work as I experienced.
Hoping to learn more as we discuss this. Thanks.
Comment #9
rlhawk@greggles - If you executed
composer require 'drupal/real_aes:^2.2', the latest version (2.4.0) was probably installed. That's what happened when I tried it. I forced the version before the patch to be installed withcomposer require 'drupal/real_aes:2.3'and observed the same dependencies being downloaded as you did.jcnventura is right that Drupal's Composer packagist does seem to do some magic to make dependencies defined in the info.yml file proper dependencies (as far as Composer is concerned) during installation, which in my test resulted in installation of Encrypt, which caused Key to be installed, even though Key is only in Encrypt's .info.yml file, not its Composer file. I did not have to require drupal/encrypt and drupal/key to get that to happen.
However, I'd prefer to be explicit about dependencies in the convention of modern PHP projects, which means specifically defining them in composer.json.
Comment #10
gregglesGreat catch, @rlhawk! That is indeed what happened. And when I did it with
composer require 'drupal/real_aes:2.2'I got an error since that version is not compatible with the Drupal 9 that my test project was running. But indeed 2.3 worked fine as you noted.I agree with your perspective that it's fine to be more explicit. It does mean there's some risk of the 2 files drifting away from each other and specifying some slightly different versions or dependencies, but that feels pretty low risk and easy to fix.
Comment #11
jcnventura@greggles, in my experience the two files drifting away from each other is exactly the real problem here. That's why it's better to define things in a single place.
I too would rather that the magic would disappear from Drupal packagist, and that module maintainers would be able to only specify dependencies via composer.json, and that the .info.yml file was optional, but at this moment it is the composer.json file that is optional.