Problem/Motivation
Only the marketing_cloud_example module lists webform as a dependency and actually uses it.
So it shouldn't be a requirement to install and use this project in my opinion.
Steps to reproduce
In my case, this requirement in the composer.json file prevented me to install the project on a Drupal 9 installation as webform 5 is not D9 compatible, only webform 6 is. See attached screenshot of when I try to install marketing_cloud with composer.
Proposed resolution
I suggest we remove the webform project as a composer dependency of marketing_cloud, but leave it as a Drupal dependency of marketing_cloud_example. If someone wants to enable it, it's their responsibility to install webform.
Another solution would be to move drupal/webform from the require section of the composer.json file to the suggest section.
And a third solution would be to allow the use of webform 6 as well as webform 5 to make it compatible with both Drupal 8 and Drupal 9.
Remaining tasks
I'll submit a patch fo implement the first solution (removing the dependency). Nothing else would be required.
However, if we decide to go with the third one (allow to use webform 6) we need to make sure that marketing_cloud is compatible with webform 6.
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#28 | 3180922-remove-webform-as-a-dependency.patch | 366 bytes | john_a |
#17 | 3180922-17.patch | 941 bytes | john_a |
#14 | 3180922-14.patch | 3.15 KB | john_a |
| |||
#12 | 3180922-12.patch | 454 bytes | john_a |
#5 | 3180922-5.patch | 302 bytes | john_a |
|
Comments
Comment #2
villette CreditAttribution: villette commentedHere's the patch
Comment #3
villette CreditAttribution: villette at Catch Digital commentedComment #4
john_a CreditAttribution: john_a as a volunteer commentedHi Villette,
Thanks for your patch and suggestions.
The issue that I had with D8, was that as a submodule, I couldn't find a way specify the dependency only for that - the dependency only seemed to work in the base module.
If we leave it out as a dependency, then I think users may get confused why the example sub-module doesn't work.
I think the solution may be to use webform 6 in composer. We cannot specify versions in the info file.
There shouldn't be any issues, unless the Webform API has changed dramatically.
Comment #5
john_a CreditAttribution: john_a as a volunteer commentedSorry it took me so long to get back. End of year was a crazy workload and I didn't even have time to breath. Looking at https://www.drupal.org/project/webform, the minimum core version for v6.0.0 if >8.8 || 9. This actually matches the core requirements for >=1.3.
So it look like we can still have webform as a dependency.
Comment #6
john_a CreditAttribution: john_a as a volunteer commentedComment #7
john_a CreditAttribution: john_a as a volunteer commentedTests pass, I'm merging this into 8.x-1.x-dev.
Comment #8
john_a CreditAttribution: john_a as a volunteer commentedComment #10
john_a CreditAttribution: john_a as a volunteer commentedComment #11
pcambraWhy is this requiring webform 6 for drupal 8? I would say that having to upgrade to webform 6 to use this module is quite the leap.
I would suggest to create releases that support both webform versions or if this is not required for the main module, add it as suggested in the composer.json instead.
Comment #12
john_a CreditAttribution: john_a as a volunteer commentedThat is a fair point, and in retrospect I think I actually agree with Villette as well.
Adding this as a suggest is a great compromise. Here's a patch for the latest version putting webform as a suggested, for testing. If this doesn't work, then I suggest recreating Villette's patch and remove it from the dependencies altogether.
Comment #13
villette CreditAttribution: villette at Catch Digital commentedHey john_a,
Sorry it took me so long to reply too.
Regarding #4, if the dependency only pertains to a sub-module (and especially an example module), I think it's more than fine to move the dependency in the suggest section of composer.
You see this behaviour very often in the Drupal ecosystem (Paragraphs Demo is an example), and as long as the sub-module's
.info.yml
file still lists webform as a dependency, it should be fine.Comment #14
john_a CreditAttribution: john_a as a volunteer commentedTests are failing, due to MarketingCloudExampleTest->testModuleFunctionality() (Test that the module can uninstall if the webform no longer exists), I think because it would be unable to install marketing_cloud_example in the first place.
Comment #15
john_a CreditAttribution: john_a as a volunteer commentedComment #16
pcambraNot sure if this would help, but you could add the key "test_dependencies" on the info file and add webform there, example: https://git.drupalcode.org/project/fraction/-/blob/2.x/fraction.info.yml, you can also leverage "require-dev" to specify which version you want, example: https://git.drupalcode.org/project/fraction/-/blob/2.x/composer.json
Comment #17
john_a CreditAttribution: john_a as a volunteer commentedFollowing is a test patch with test_dependencies in marketing_cloud_example.info.yml.
Comment #18
john_a CreditAttribution: john_a as a volunteer commentedI actually can't find a way around it.
The composer requirements can only go in the main module, not in the sub-modules. So that means whatever required modules a sub-module needs, must be defined in the ,ain composer.json file - thus must be installed when the main module is installed.
So we can have dependencies defined in the .info.yml file for a sub-module, This will give a prompt to the user of they try to enable marketing_cloud_example, and drupal 'should' pre-install the views module.
Adding it as a suggest in composer.json is a half-decent workaround.
The tests for marketing_cloud_example will have to be removed though. There is no way that I could find to pre-install the dependencies for the tests. So I suggest we go with #14.
Does everyone agree?
Comment #19
pcambraPlease be aware that Drupal CI doesn't apply composer patches or the test dependencies , you need to push in a try and error, so I would suggest to try #17 and see if the tests pass on the Automated testing tab of the module
Comment #20
john_a CreditAttribution: john_a as a volunteer commentedHi pcambra,
As you can see, I had already tried doing tests on the patch, which failed (https://www.drupal.org/pift-ci-job/1974155):
So I think this is a no-go...
Comment #21
pcambraThat's not going to work, you need to push directly the changes on the composer.json and info.yml file first and then test, the CI will not do that for you, unfortunately.
Not a lot of docs but some comments here and there describing the issue https://www.drupal.org/project/drupalci/issues/3157542
I managed to do this on fraction module: https://www.drupal.org/project/fraction/issues/3097527
Comment #22
john_a CreditAttribution: john_a as a volunteer commentedI've committed #17 to the dev branch, and you you're correct pcambra. Good spot.
The D9 tests only failed by an invalid test case of
MarketingCloudTest::testMarketingCloudSession Failed asserting that null is false
. This is expected and resolved in a separate ticket.Comment #23
john_a CreditAttribution: john_a as a volunteer commentedFor testing on this, you'll need to checkout the dev version: 8.x-1.x-dev, and then install
Comment #24
john_a CreditAttribution: john_a as a volunteer commentedAssuming there's no feedback on this, i'm going to mark this is ready and it'll be in the next release
Comment #25
john_a CreditAttribution: john_a as a volunteer commentedComment #27
john_a CreditAttribution: john_a as a volunteer commentedDammit, D8.9.12 tests now fail, due to:
Here's a patch to just remove the dependency altogether
Comment #28
john_a CreditAttribution: john_a as a volunteer commentedbad patch, new version
Comment #31
john_a CreditAttribution: john_a as a volunteer commented