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

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

parent 315cfaab
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -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();
   }
  }
}
+1 −1
Original line number Diff line number Diff line
@@ -3,4 +3,4 @@ status: false
dependencies: {  }
formId: contact_message_feedback_form
captchaType: default
label: null
label: contact_message_feedback_form
+1 −1
Original line number Diff line number Diff line
@@ -3,4 +3,4 @@ status: false
dependencies: {  }
formId: contact_message_personal_form
captchaType: default
label: null
label: contact_message_personal_form
+1 −1
Original line number Diff line number Diff line
@@ -3,4 +3,4 @@ status: false
dependencies: {  }
formId: user_login_form
captchaType: default
label: null
label: user_login_form
+1 −1
Original line number Diff line number Diff line
@@ -3,4 +3,4 @@ status: false
dependencies: {  }
formId: user_pass
captchaType: default
label: null
label: user_pass
Loading