Problem/Motivation
Hello,
When I run the drush "site-install" command, it throws the following error: The Math question field is required.
This error occurs when Drupal executes the "install_configure_form" task when the "enable_globally" configuration is set to 1.
If I set it to 0, I don't get this error.
The Drupal installation uses a Drupal form for this task (see web/core/includes/install.core.inc line 815), and it seems that the captcha is automatically generated in the form.
Steps to reproduce
- From an existing site (tested with Drupal 11.1.6), with the Captcha module enabled.
- Enable captchas on all forms (set the "enable_globally" property to 1 in the captcha.settings.yml file)
- Export the configuration
- Reinstall the site with Drush using the existing configurations:
vendor/bin/drush site-install minimal --existing-config ... - The error "The field Math question is required." appears immediately after the "install_import_translations" task (if "locale" is enabled), otherwise after the "install_config_revert_install_changes" task.
Proposed resolution
To work around the problem, I had to create a "captcha_point" for "install_configure_form" where I disable the captcha.
Example:
uuid: aa47f69a-7e7b-4b8f-9ead-94907dc0fed7
langcode: fr
status: false
dependencies: { }
_core:
default_config_hash: XbughDuwgOtc_8ztmYxz84gaXBeR760xH3bGSKD9v1Q
formId: install_configure_form
captchaType: default
label: 'install_configure_form (needed to prevent error on drush site-install)'
Remaining tasks
As a long-term solution, I propose adding a condition in the captcha_form_alter method to prevent the captcha from being added to the install_configure_form form.
Do you have a better suggestion?
Issue fork captcha-3526792
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
Comment #2
s3b0un3tComment #3
avpadernoComment #4
aherczeg commentedComment #6
aherczeg commentedComment #8
peri22 commentedAdded a kernel test: it fails on 2.x with the reported "Math question field is required" error and passes with the MR applied.
RTBC.
Comment #9
japerryI've pushed one change on top of the MR. Instead of matching the install_configure_form ID, the hook now returns early when InstallerKernel::installationAttempted() is true. That also covers install-time forms that profiles and distributions add, which would fail the same way, and nobody wants CAPTCHA in the installer anyway. Once installation finishes, the global CAPTCHA applies as before.
Tests:
Comment #11
japerry