Try to parse version in composer if not in .info.yml

Created on 16 May 2024, 6 months ago
Updated 17 July 2024, 4 months ago

Problem/Motivation

From #3440128: version in info.yml for general project β†’ , when using an installation profile, there is no "version" put automatically in .info.yml file of the profile and in its modules/themes .info.yml files.

This will provoke a fatal error on status report page due to:

TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given, called in /project/app/core/lib/Drupal/Component/Render/FormattableMarkup.php on line 256 in Drupal\Component\Utility\Html::escape() (line 431 of core/lib/Drupal/Component/Utility/Html.php).
Drupal\Component\Render\FormattableMarkup::placeholderEscape(NULL) (Line: 229)
Drupal\Component\Render\FormattableMarkup::placeholderFormat('%profile_name (%profile-%version)', Array) (Line: 195)
Drupal\Core\StringTranslation\TranslatableMarkup->render() (Line: 15)
Drupal\Core\StringTranslation\TranslatableMarkup->__toString() (Line: 336)
Twig\Template->render(Array) (Line: 38)
Twig\TemplateWrapper->render(Array) (Line: 39)
twig_render_template('core/themes/claro/templates/status-report-grouped.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('status_report_grouped', Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 203)
Drupal\Core\Render\Renderer->render(Array) (Line: 475)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 80)
__TwigTemplate_71280d5a17f166e234dcd7a30c6eb76d->doDisplay(Array, Array) (Line: 360)
Twig\Template->yield(Array) (Line: 335)
Twig\Template->render(Array) (Line: 38)
Twig\TemplateWrapper->render(Array) (Line: 39)
twig_render_template('core/themes/claro/templates/status-report-page.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('status_report_page', Array) (Line: 446)
...

Also it would be nice that this kind of information would be handled with Composer data directly. Not only for installation profile, but also for modules and themes.

Steps to reproduce

Install a module in dev version using composer composer require drupal/address:2.0.x-dev.
On admin/modules, there is no indicated version for the module.

Proposed resolution

Try to get data from Composer.

Remaining tasks

- POC: done in MR
- handle sub-extensions
- handle tests extensions?
- if possible make the hardcoded 'drupal/' dynamic
- write tests

User interface changes

Versions of extensions not present in .info.yml but handled with Composer will be displayed on the admin pages.

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
ExtensionΒ  β†’

Last updated about 19 hours ago

No maintainer
Created by

πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Grimreaper
  • Pipeline finished with Canceled
    6 months ago
    Total: 18s
    #174525
  • Issue was unassigned.
  • Status changed to Needs work 6 months ago
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Attaching patch for Composer usage.

  • Pipeline finished with Failed
    6 months ago
    Total: 666s
    #174526
  • Status changed to Needs review 6 months ago
  • πŸ‡΅πŸ‡°Pakistan isalmanhaider

    +1
    @grimreaper, I support the proposed resolution to parse version information from Composer when not available in .info.yml.

    This change will improve consistency and prevent errors on the status report page, ensuring that version information is reliably available. Leveraging Composer for this purpose aligns with best practices in dependency management and enhances the overall reliability of the system.

  • Status changed to Needs work 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Didn't check the Unit failure to see if related but definitely something that will need test coverage.

  • Pipeline finished with Success
    6 months ago
    Total: 693s
    #175731
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    @isalmanhaider thanks for your interest in the proposed resolution.

    @smustgrave the existing tests failure was related. I have fixed it.

    Status needs to remain "needs work" because of all the other remaining tasks to discuss/to do (implementing new tests is of course among the remaining points).

  • πŸ‡³πŸ‡ΏNew Zealand quietone
Production build 0.71.5 2024