Form Protection causes `cv` to fail on Drupal 9+
When Form Protection is enabled, cv
will fail with this error:
[Drupal\Core\DependencyInjection\ContainerNotInitializedException]
\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.
This is because the settings
files are called very early in the bootstrap, and the settings file has this line:
'description' => E::ts('Display a <a href="%1">ReCAPTCHA</a> when there are errors.', [1 => CRM_Utils_System::url('civicrm/admin/setting/recaptcha', 'reset=1')]),
CRM_Utils_System::url()
is...not great on D9+, and it's something I've spent a lot of time trying to fix (with limited success). But essentially, url()
is getting passed off to Drupal itself, which isn't bootstrapped here.
Looking at this line - I'm even wondering if this description is still accurate. It links to /civicrm/admin/setting/recaptcha
- but doesn't modern Form Protection use its own ReCAPTCHA?
A quick test suggests this path is invalid. I'll submit a MR to amend the description.