Problem/Motivation

I was getting this cryptic error message after running the quick-start command:

In install.core.inc line 2293:
PHP extensions: Disabled
Array

It didn't say what extension was missing, but opening a PHP server with php -S 127.0.0.1:8000/core/install.php I got this at the "Verify requirements" stage:

PHP extensions
Disabled
Drupal requires you to enable the PHP extensions in the following list (see the system requirements page for more information):

  • dom
  • SimpleXML
  • xml

Installing php-xml fixed it.

Steps to reproduce

Uninstall a required Drupal Quick Start PHP extension (for example php-xml) and see that it isn't shown which extension is missing:

  1. Find installed PHP XML extension versions and uninstall them:
    $ dpkg --get-selections | grep -i php | grep xml
    php-xml           install
    php7.4-xml          install
    $ sudo apt remove --purge php-xml php7.4-xml
    
  2. Run the quick-start command, and see that it fails with the error above.

  3. Install the PHP XML extension, run quick-start, and see that it completes.
    $ sudo apt install php-xml

Proposed resolution

Fix the code around line https://git.drupalcode.org/project/drupal/-/blob/9.3.x/core/includes/ins... to show the missing PHP extension(s).

Comments

ressa created an issue. See original summary.

ressa’s picture

Issue summary: View changes
ressa’s picture

Version: 9.2.x-dev » 9.3.x-dev
Issue summary: View changes
ressa’s picture

Issue summary: View changes
cilefen’s picture

Is install_display_requirements actually broken or is this more of a CLI display-time issue?

longwave’s picture

Issue tags: +Bug Smash Initiative

This is a bug in install_display_requirements(), or at least an incorrect assumption.

system_requirements() builds the description as a render array as follows:

  $requirements['php_extensions'] = [
    'title' => t('PHP extensions'),
  ];
...
    $description = t('Drupal requires you to enable the PHP extensions in the following list (see the <a href=":system_requirements">system requirements page</a> for more information):', [
      ':system_requirements' => 'https://www.drupal.org/docs/system-requirements',
    ]);

    // We use twig inline_template to avoid twig's autoescape.
    $description = [
      '#type' => 'inline_template',
      '#template' => '{{ description }}{{ missing_extensions }}',
      '#context' => [
        'description' => $description,
        'missing_extensions' => [
          '#theme' => 'item_list',
          '#items' => $missing_extensions,
        ],
      ],
    ];

    $requirements['php_extensions']['value'] = t('Disabled');
    $requirements['php_extensions']['severity'] = REQUIREMENT_ERROR;
    $requirements['php_extensions']['description'] = $description;

But then in install_display_requirements() it is assumed that the description is a string, and it is concatenated directly:

          $failures[] = $requirement['title'] . ': ' . $requirement['value'] . "\n\n" . $requirement['description'];

The hook_requirements() doc does not state the format of the description key, it only says:

 *   - description: The description of the requirement/status.
longwave’s picture

ressa’s picture

Thanks @cilefen and @longwave, I'll try the patch in #2833864: Unmet installation requirements may contain render elements.

I just made two images to show the situation and will post them anyway. They show that the installer works fine in the browser where missing PHP extensions are shown, but not using the quick-start from CLI:

Command line, "Array" is shown

Only local images are allowed.

Browser, missing PHP extensions are shown

Only local images are allowed.