Problem/Motivation

After #3123996: Check if composer.json is not Drupal 9 compatible, if it exists, the report generates a warning if composer.json does not include drupal/core as a requirement. For example, "require": {} leads to a warning.

In fact, a missing requirement is not a problem. For modules hosted on d.o, we already have #3084063: Use information in info.yml files to determine project requirements.

Proposed resolution

Either completely remove the test added in #3123996 or make it more specific. For example, "require": {"drupal/core": "^8.0"} should lead to an error (not just a warning).

Remaining tasks

User interface changes

Do not generate unnecessary warnings.

API changes

None

Data model changes

None

Release notes snippet

CommentFileSizeAuthor
#14 3126949-14.patch930 bytesgábor hojtsy
#5 3126949.patch1.73 KBgábor hojtsy

Comments

benjifisher created an issue. See original summary.

gábor hojtsy’s picture

Good find thanks!

gábor hojtsy’s picture

Status: Active » Needs review
StatusFileSize
new1.73 KB

Removing the existence check and adjusting the error message about the drupal/core requirement if present but not compatible. Looks good? :)

Also crediting folks from the slack thread for discovery.

gábor hojtsy’s picture

Category: Task » Bug report

gábor hojtsy’s picture

gábor hojtsy’s picture

Is there a good documentation link we can point to to explain what is going on here btw? That would be ideal.

benjifisher’s picture

Status: Needs review » Needs work

The patch looks right, although the revised error message is a little long:

-          'message' => "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.",
+          'message' => "The drupal/core requirement is not Drupal 9 compatible. Having a composer.json is not a requirement for Drupal 9 compatibility. Even if there is a composer.json file, it is not necessary to have a drupal/core requirement defined in it. But if there is a composer.json file and the drupal/core requirement is defined in it, it should be defined as compatible with Drupal 9.",

Maybe something more prescriptive would be better:

The drupal/core requirement is not Drupal 9 compatible. Either remove it or update it to be compatible with Drupal 9. Having a composer.json is not a requirement for Drupal 9 compatibility.

Consider removing the last sentence: I do not think we want to encourage module maintainers to remove composer.json.

I tried to test locally, but now I get

Server error: `POST https://drupal.lndo.site/admin/reports/upgrade-status/analyze/module/typ...` resulted in a `500 500 Service unavailable (with message)` response: The website encountered an unexpected error. Please try again later.

Any idea where that comes from? I did update Lando and rebuild my containers since the earlier test.

benjifisher’s picture

I think the standard documentation about composer.json is https://www.drupal.org/docs/8/creating-custom-modules/add-a-composerjson.... You might want to add a section there about the best practices for D9 compatibility.

Related: https://www.drupal.org/docs/8/creating-custom-modules/let-drupal-8-know-.... This already has good information on core_version_requirement and core: 8.x.

  • Gábor Hojtsy committed d506b70 on 8.x-2.x
    Issue #3126949 by Gábor Hojtsy, benjifisher, Mixologic, drumm, Berdir:...
gábor hojtsy’s picture

Status: Needs work » Fixed

Great, I added some docs to https://www.drupal.org/docs/8/creating-custom-modules/add-a-composerjson... and linked that in. Also added a link to that page to the parse error as well.

The 500 error would be great to figure out, I don't know why that is the case, did you try with the dev version (2.2 had a problem that could cause a 500 error).

Either way, closing this as the scope has been resolved :)

Thanks for all your help and thorough investigation everyone.

gábor hojtsy’s picture

Status: Fixed » Needs review
StatusFileSize
new930 bytes

The missing key was now generating a notice. Duh. Should eventually add some decent test coverage for this :D

gábor hojtsy’s picture

  • Gábor Hojtsy committed 0e71712 on 8.x-2.x
    Issue #3126949 followup by Gábor Hojtsy, jastraat: Resolve notice and...
gábor hojtsy’s picture

Status: Needs review » Fixed

Committed that.

Status: Fixed » Closed (fixed)

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