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.

Issue fork drupal-3447672

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

Grimreaper created an issue. See original summary.

grimreaper’s picture

Assigned: grimreaper » Unassigned
Issue summary: View changes
Status: Active » Needs work
StatusFileSize
new2.37 KB

Attaching patch for Composer usage.

isalmanhaider’s picture

Status: Needs work » Needs review

+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.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

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

grimreaper’s picture

@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).

quietone’s picture

Version: 11.0.x-dev » 11.x-dev
grimreaper’s picture

StatusFileSize
new1.6 KB

MR now targeting 11.x.

Rebased.

And changes updated to handle dev version of packages.

idebr’s picture

This feature is available through contrib, see https://www.drupal.org/project/composer_deploy

grimreaper’s picture

Thanks for the link, I will give a look.

It would be better to avoid the need a contrib module for that, and Core to be able to handle it by itself.

grimreaper’s picture

StatusFileSize
new3.53 KB

Patch from MR current state.

dww’s picture

I need to make time to closely review this and help it along. Meanwhile, #2559313 is closely related.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.