Fix #3627745: Fix multiple install requirement errors

Changes

On install, core displays the description of each requirement error. If the error also has a value, core shows it as a version number: "(Currently using … version …)". Every error that can come up on install now has a string description and no value. Both requirement classes state this rule in their docblock. In RequirementsChecker, the rule applies only to errors reachable on install: the request tracking error keeps its value, because install reads the default configuration, where request tracking is disabled.

  • RequirementsChecker::checkDatabaseAliasConsistency()
    • Missing logger alias: the message moves from value to description. Without a description, core passed NULL to Html::escape(), which is typed string since 11.0.0. That threw a TypeError on 11.x and 12.x; 10.x showed the message as a version number.
    • logger alias on the same database as another alias: both sentences are joined into the description, instead of one being shown as a version number.
  • MongodbRequirements::checkDatabases()
    • Now sets its own error, like the other check*() methods. A database referencing an undefined client used to have an item list render array as its description, which threw a TypeError on 10.x, 11.x and 12.x. The description is now a string: "Inconsistent database/client settings.", the former value, followed by the "undefined client" messages. The item list is kept for a valid configuration.
    • A client with an empty configuration ('default' => []) is now accepted, because ClientFactory gives it the default URI. The check now uses array_key_exists() instead of empty().
  • MongodbRequirements::checkExtension(): the "Extension not loaded" value, which was shown as a version number, now starts the description.
  • MongodbRequirements::checkExtensionVersion(): when the check fails, the version message is now also the description. That error had neither value nor description, so it showed an empty message.

Where an error lost its value, the summary now starts its description, so it still shows on the status report and update.php. One new translatable string: "Extension not loaded." The former value had no period.

docs/install.md: documents that each client key is optional, with its default, so 'default' => [] is a valid client. It also says that every client alias used in databases must be defined in clients, or install and the status report fail with "Inconsistent database/client settings."

Testing

New kernel tests call drupal_check_module() with the settings for each case and check the exact error messages. They need no MongoDB server.

  • RequirementsCheckerTest: missing logger alias, and logger alias on the same database as another alias.
  • MongodbRequirementsTest: a client with an empty configuration is accepted. Databases referencing undefined clients are reported: the test uses two of them, so it also checks that the messages are joined after the summary.

ClientFactoryTest: testGetHappy() and testGetSadBadAlias() become one testGet() with a data provider. It covers the client config shapes that work (test server, empty client, URI only, URI with options) and those that fail (unreachable server, malformed URI, non-string URI, non-array uriOptions). Only the test server and unreachable server cases connect. The others check the client URI without connecting, because the CI server is not on localhost.

Results

  • On 11.4, without the fix, the new requirement tests fail with the TypeError and the "(Currently using … version …)" message. With the fix they pass.
  • The full module test suite passes on 11.4, and phpcs reports no errors.
  • The new tests also pass on 12.x.
  • The full module test suite also passes on 10.6 and 12.0.0-beta1 (tested by fgm in #13).
  • The extension errors have no tests: they need PHP without the extension, or an older version of it.

Closes #3627745

AI Disclosure: I used Claude Code to debug and make the code changes for this MR. And to help write the MR description.

Edited by Matt Hand

Merge request reports

Loading
Loading