The project needs a composer.json for Drupal CI automated tests to work Drupal 9 tests.


Having a new warning after Updating Upgrade Status 8.x-2.2 released 10 April 2020

#3123996: Check if composer.json is not Drupal 9 compatible, if it exists

The drupal/core requirement is not Drupal 9 compatible. Having a composer.json is not a requirement for Drupal 9 compatibility but if there is one, it should include a drupal/core requirement compatible with Drupal 9.

For example:

composer create-project drupal/recommended-project:~9 /var/www/html/test/drupal9test1allowed_formats -vvv
cd /var/www/html/test/drupal9test1allowed_formats

And then
composer require 'drupal/allowed_formats:^1.0'
or the dev branch
composer require 'drupal/allowed_formats:1.x-dev'

Find out that in the .info.yml
We do have ^8.7.7 || ^9
It could be changed to ^8 || ^9 or ^8.8 || ^9 or ^8.7.7 || ^8 || ^9
To have it work for both Drupal 8 and Drupal 9

When we test in Drupal 9 we can get the following issue

    - drupal/allowed_formats 1.x-dev requires drupal/core ^8.7.7 || ^9 -> satisfiable by drupal/core[8.7.10, 8.7.11, 8.7.12, 8.7.13, 8.7.14, 8.7.7, 8.7.8, 8.7.9, 8.7.x-dev, 8.8.0, 8.8.0-alpha1, 8.8.0-beta1, 8.8.0-rc1, 8.8.1, 8.8.2, 8.8.3, 8.8.4, 8.8.5, 8.8.6, 8.8.7, 8.8.8, 8.8.x-dev, 8.9.0, 8.9.0-beta1, 8.9.0-beta2, 8.9.0-beta3, 8.9.0-rc1, 8.9.1, 8.9.x-dev, 9.0.0, 9.0.0-alpha1, 9.0.0-alpha2, 9.0.0-beta1, 9.0.0-beta2, 9.0.0-beta3, 9.0.0-rc1, 9.0.1, 9.0.x-dev, 9.1.x-dev].
    - Can only install one of: drupal/core[9.0.0-alpha1, 8.7.1].
    - Can only install one of: drupal/core[9.0.x-dev, 8.7.1].
    - Can only install one of: drupal/core[9.1.x-dev, 8.7.1].
    - Can only install one of: drupal/core[8.8.0-alpha1, 8.7.1].
    - Can only install one of: drupal/core[8.8.x-dev, 8.7.1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.1].
    - Can only install one of: drupal/core[8.7.x-dev, 8.7.1].
    - Conclusion: install drupal/core 8.7.1


It's important to update the composer with the full project set of config and have the following.
+  "require": {
+    "drupal/core": "^8 || ^9"
+  }

Comments

Mohammed J. Razem created an issue. See original summary.

gnanagowthaman sankar’s picture

Assigned: Unassigned » gnanagowthaman sankar
Status: Active » Needs review
StatusFileSize
new897 bytes

Hi @Mohammed J. Razem,

Here by i attached the patch. Please review and let me know for the changes.

Thanks & regards,
Gnanagowthaman Sankar

mohammed j. razem’s picture

Status: Needs review » Needs work

Patch is not applying.

mohammed j. razem’s picture

Issue summary: View changes
gnanagowthaman sankar’s picture

Status: Needs work » Needs review
StatusFileSize
new261 bytes
new940 bytes

Hi @Mohammed J. Razem,

I modified the patch. Please review and let me know for changes.

Thanks & regards,
GnanagowthamanSankar

rajab natshah’s picture

Title: Add composer.json » Fix composer file for Allowed Formats to work with Drupal 9 and Drupal CI
Assigned: gnanagowthaman sankar » Unassigned
Issue summary: View changes
Status: Needs review » Needs work
rajab natshah’s picture

StatusFileSize
new1.3 KB
rajab natshah’s picture

Status: Needs work » Needs review
rajab natshah’s picture

StatusFileSize
new1.3 KB
rajab natshah’s picture

rajab natshah’s picture

rajab natshah’s picture

StatusFileSize
new1.27 KB
rajab natshah’s picture

rajab natshah’s picture

Find out that in the .info.yml
We do have ^8.7.7 || ^9
It should be changed to ^8 || ^9
To have it work for both Drupal 8 and Drupal 9

When we test in Drupal 9 we can get the following issue

    - drupal/allowed_formats 1.x-dev requires drupal/core ^8.7.7 || ^9 -> satisfiable by drupal/core[8.7.10, 8.7.11, 8.7.12, 8.7.13, 8.7.14, 8.7.7, 8.7.8, 8.7.9, 8.7.x-dev, 8.8.0, 8.8.0-alpha1, 8.8.0-beta1, 8.8.0-rc1, 8.8.1, 8.8.2, 8.8.3, 8.8.4, 8.8.5, 8.8.6, 8.8.7, 8.8.8, 8.8.x-dev, 8.9.0, 8.9.0-beta1, 8.9.0-beta2, 8.9.0-beta3, 8.9.0-rc1, 8.9.1, 8.9.x-dev, 9.0.0, 9.0.0-alpha1, 9.0.0-alpha2, 9.0.0-beta1, 9.0.0-beta2, 9.0.0-beta3, 9.0.0-rc1, 9.0.1, 9.0.x-dev, 9.1.x-dev].
    - Can only install one of: drupal/core[9.0.0-alpha1, 8.7.1].
    - Can only install one of: drupal/core[9.0.x-dev, 8.7.1].
    - Can only install one of: drupal/core[9.1.x-dev, 8.7.1].
    - Can only install one of: drupal/core[8.8.0-alpha1, 8.7.1].
    - Can only install one of: drupal/core[8.8.x-dev, 8.7.1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.1].
    - Can only install one of: drupal/core[8.7.x-dev, 8.7.1].
    - Conclusion: install drupal/core 8.7.1

rajab natshah’s picture

StatusFileSize
new1.67 KB
rajab natshah’s picture

Issue summary: View changes
bramdriesen’s picture

Status: Needs review » Needs work
+++ b/allowed_formats.info.yml
@@ -1,7 +1,7 @@
-core_version_requirement: ^8.7.7 || ^9

I assume this was actually set to 8.7.7 for a reason.

rajab natshah’s picture

Thank you Bram for the notice.
- core_version_requirement: ^8.7.7 || ^9
will not allow to be installed in ^8.8 for example

To have the full test cases with physical Drupal core files

  • Install Drupal 8.7.* -- try to use composer and install ( it will work )
  • Install Drupal 8.8.* -- try to use composer and install ( Did not work)
  • Install Drupal 9.* -- try to use composer and install ( Did not work)

^8.7.7 is stronger than ^8.7
It will force to use Drupal 8.7.*

Caret Version Range (^)

https://getcomposer.org/doc/articles/versions.md#caret-version-range-

The ^ operator behaves very similarly but it sticks closer to semantic versioning, and will always allow non-breaking updates. For example ^1.2.3 is equivalent to >=1.2.3 <2.0.0 as none of the releases until 2.0 should break backwards compatibility. For pre-1.0 versions it also acts with safety in mind and treats ^0.3 as >=0.3.0 <0.4.0.

This is the recommended operator for maximum interoperability when writing library code.

Please have a look at
Versions and constraints

rajab natshah’s picture

When we test in Drupal 9 or Drupal 8.8.* we can get the following issue

    - drupal/allowed_formats 1.x-dev requires drupal/core ^8.7.7 || ^9 -> satisfiable by drupal/core[8.7.10, 8.7.11, 8.7.12, 8.7.13, 8.7.14, 8.7.7, 8.7.8, 8.7.9, 8.7.x-dev, 8.8.0, 8.8.0-alpha1, 8.8.0-beta1, 8.8.0-rc1, 8.8.1, 8.8.2, 8.8.3, 8.8.4, 8.8.5, 8.8.6, 8.8.7, 8.8.8, 8.8.x-dev, 8.9.0, 8.9.0-beta1, 8.9.0-beta2, 8.9.0-beta3, 8.9.0-rc1, 8.9.1, 8.9.x-dev, 9.0.0, 9.0.0-alpha1, 9.0.0-alpha2, 9.0.0-beta1, 9.0.0-beta2, 9.0.0-beta3, 9.0.0-rc1, 9.0.1, 9.0.x-dev, 9.1.x-dev].
    - Can only install one of: drupal/core[9.0.0-alpha1, 8.7.1].
    - Can only install one of: drupal/core[9.0.x-dev, 8.7.1].
    - Can only install one of: drupal/core[9.1.x-dev, 8.7.1].
    - Can only install one of: drupal/core[8.8.0-alpha1, 8.7.1].
    - Can only install one of: drupal/core[8.8.x-dev, 8.7.1].
    - Can only install one of: drupal/core[8.9.x-dev, 8.7.1].
    - Can only install one of: drupal/core[8.7.x-dev, 8.7.1].
    - Conclusion: install drupal/core 8.7.1

rajab natshah’s picture

Issue summary: View changes

It could be changed to ^8 || ^9 or ^8.8 || ^9 or ^8.7.7 || ^8 || ^9

grayle’s picture

StatusFileSize
new418 bytes

Time stops for no man. I'd suggest ^8.8 || ^9, and remove the requirement from composer.json. Drupal.org should take care of that one on its own.

https://www.drupal.org/node/3070687

It is also possible to specify the same requirement in composer.json, but if no drupal/core requirement is defined there, one will automatically be generated based on core_version_requirement.

grayle’s picture

StatusFileSize
new1.26 KB

Or with composer.json file for fanciness. Still no core requirement, also removed repositories entry. Doesn't work anyway for dependencies.

https://getcomposer.org/doc/faqs/why-can%27t-composer-load-repositories-...

grayle’s picture

Status: Needs work » Needs review
bramdriesen’s picture

Status: Needs review » Reviewed & tested by the community

Looks great to me :-)

rajab natshah’s picture

We do need the following in the composer

+  "require": {
+    "drupal/core": "^8 || ^9"
+  }

as in patch #15
we do not have that or require in #22

rajab natshah’s picture

Real physical testing with Drupal 9 is important in this case

For example:

composer create-project drupal/recommended-project:~9 /var/www/html/test/drupal9test1allowed_formats -vvv
cd /var/www/html/test/drupal9test1allowed_formats

And then
composer require 'drupal/allowed_formats:^1.0'
or the dev branch
composer require 'drupal/allowed_formats:1.x-dev'

grayle’s picture

I don't know if drupal.org does it for the dev branch, but for actual releases it adds in the drupal/core requirement.

It is also possible to specify the same requirement in composer.json, but if no drupal/core requirement is defined there, one will automatically be generated based on core_version_requirement.

Unless it isn't working. It can't hurt to put it in afaik, it's just essentially duplication of code.

rajab natshah’s picture

#3123996: Check if composer.json is not Drupal 9 compatible, if it exists

The drupal/core requirement is not Drupal 9 compatible. Having a composer.json is not a requirement for Drupal 9 compatibility but if there is one, it should include a drupal/core requirement compatible with Drupal 9.

grayle’s picture

StatusFileSize
new28.45 KB

Is it specifically for CI that we're trying to fix stuff? Because I'll be honest, don't have too much experience with that thing so chances are that you'll indeed have to add it to composer.json to have it run correctly if something's wonky there.

But I've applied my patch locally, and ran upgrade status (2.9) and it says everything is a-ok.

And I can require this module's 1.3 release in a drupal 9 project as well.

composer require in D9

That's in a fresh D9 created with composer create-project drupal/recommended-project:^9.0 drupal9

rajab natshah’s picture

nord102’s picture

Re-rolled to accommodate ^8.8 || ^9 for the info.yml > core_version_requirement and composer.json > require

  • nord102 authored 7b7e7d9 on 8.x-1.x
    Issue #3151386 by Rajab Natshah, Grayle, Gnanagowthaman sankar, nord102...
nord102’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.