Problem/Motivation

qr_generator 2.x declares core_version_requirement: ^10.3 || ^11 but cannot be installed on Drupal 10. drush en qr_generator fails with:

In EntityTypeManager.php line 142: The "qr_code" entity type does not exist.

The QRCode entity is defined only with the #[ContentEntityType] attribute. Entity type attributes (Drupal\Core\Entity\Attribute\ContentEntityType) were added in Drupal 11.1, and Drupal 10 discovers entity types only through annotations. The install stops partway: the module is marked as enabled in core.extension, but no entity type, database tables or install config are created. The affected releases are 2.0.0 to 2.0.3.

Steps to reproduce

  1. Drupal 10.6.x site (tested on 10.6.17, PHP 8.2).
  2. composer require drupal/qr_generator:^2.0
  3. drush en qr_generator -y fails with the error above.

Proposed resolution

Add an equivalent @ContentEntityType annotation in the docblock next to the existing attribute. Drupal 11.1+ keeps using the attribute and Drupal 10 uses the annotation. This is the usual way to support both core versions.

No other changes are needed. The #[Hook]/#[LegacyHook] attributes are never instantiated on Drupal 10, and the procedural wrappers in qr_generator.module still run. All other core classes the module uses exist in Drupal 10.

Tested on Drupal 10.6.17 / PHP 8.2:

  • The module installs; the qr_code entity type, its tables and all install config are created.
  • Entity create/view/delete and PNG export work.
  • phpcs (Drupal, DrupalPractice) passes.

Remaining tasks

  • Review the patch/MR.
  • Test on Drupal 11.1+ to confirm nothing changes there.

User interface changes

None.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    Comments

    akhilsoni created an issue. See original summary.

    • 6335abd8 committed on main
      Issue #3626716 by akhilsoni: Module cannot be installed on Drupal 10:...

    • 6335abd8 committed on 2.x
      Issue #3626716 by akhilsoni: Module cannot be installed on Drupal 10:...
    m.evans’s picture

    Status: Needs review » Fixed

    Thanks @akhilsoni for the clear report and the patch!

    I reviewed the patch and confirmed that the annotation matches the existing attribute. I also tested it on Drupal 10.3 and Drupal 11.3.3. On both versions the module installs correctly, the qr_code entity type and its tables are created, and creating, viewing and deleting QR codes works as expected.

    The fix has been committed to 2.0.x and is included in the new 2.0.4 release.

    Note for anyone who tried to install 2.0.0–2.0.3 on Drupal 10: the failed install may have left the module marked as enabled without its database tables. After updating to 2.0.4, run drush pmu qr_generator and then drush en qr_generator to reinstall it cleanly.

    Now that this issue is closed, review the contribution record.

    As a contributor, attribute any organization that helped you, or if you volunteered your own time.

    Maintainers, credit people who helped resolve this issue.

    m.evans’s picture

    Status: Fixed » Closed (fixed)