Commit 61fe1eae authored by Suhyeon Hong's avatar Suhyeon Hong Committed by Jakob Perry
Browse files

Issue #3293710 by suhyeon: CAPTCHA point form ID is set to null

parent 315cfaab
......@@ -112,15 +112,18 @@ function captcha_install() {
if (!\Drupal::service('config.installer')->isSyncing() && \Drupal::moduleHandler()->moduleExists('node')) {
$form_ids = [];
$label = [];
// Add form_ids of all currently known node types too.
foreach (node_type_get_names() as $type => $name) {
$form_ids[] = 'node_' . $type . '_form';
$label[] = 'node_' . $type . '_form';
}
$captcha_storage = \Drupal::entityTypeManager()
->getStorage('captcha_point');
foreach ($form_ids as $form_id) {
foreach ($form_ids as $index=>$form_id) {
$values = [
'label' => $label[$index],
'formId' => $form_id,
'captchaType' => 'default',
'status' => FALSE,
......@@ -143,3 +146,23 @@ function captcha_update_8901(&$sandbox) {
->installEntityType($entityType);
}
}
/**
* Implements hook_update_N().
*/
function captcha_update_8902(&$sandbox) {
$query = \Drupal::entityQuery('captcha_point');
$query->notExists('label');
$entity_ids = $query->execute();
if (!empty($entity_ids) && is_array($entity_ids)) {
foreach($entity_ids as $entity_id) {
$captcha_point_id = $entity_id;
$captcha_point = \Drupal::entityTypeManager()
->getStorage('captcha_point')
->load($captcha_point_id);
$captcha_point->set('label', $captcha_point->getFormId());
$captcha_point->save();
}
}
}
......@@ -3,4 +3,4 @@ status: false
dependencies: { }
formId: contact_message_feedback_form
captchaType: default
label: null
label: contact_message_feedback_form
......@@ -3,4 +3,4 @@ status: false
dependencies: { }
formId: contact_message_personal_form
captchaType: default
label: null
label: contact_message_personal_form
......@@ -3,4 +3,4 @@ status: false
dependencies: { }
formId: user_login_form
captchaType: default
label: null
label: user_login_form
......@@ -3,4 +3,4 @@ status: false
dependencies: { }
formId: user_pass
captchaType: default
label: null
label: user_pass
......@@ -3,4 +3,4 @@ status: false
dependencies: { }
formId: user_register_form
captchaType: default
label: null
label: user_register_form
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment