Problem/Motivation

In hook acquia_optimize_form_node_form_alter there a Race condition which we need to avoid https://git.drupalcode.org/project/acquia_optimize/-/blob/1.x/acquia_opt...

Proposed resolution

Use form state storage for tracking state instead of user input, something like this:

$stage = $form_state->get('acquia_optimize_stage') ?: 'initial';
  $form_state_input = $form_state->getUserInput();
  $is_ajax = array_key_exists('_drupal_ajax', $form_state_input) && $form_state_input['_drupal_ajax'] === '1';
  
  if ($is_ajax && $form_state->getTriggeringElement()['#name'] === 'acquia_optimize_scan_button') {
    $form_state->set('acquia_optimize_stage', 'scanning');
    $stage = 'scanning';
  }

Or please feel free to implement a better approach.

Command icon 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

ankitv18 created an issue. See original summary.

vishalkhode made their first commit to this issue’s fork.

ankitv18’s picture

Version: 1.1.0 » 1.x-dev
Status: Active » Needs review
vipin.mittal18’s picture

Category: Task » Bug report
Status: Needs review » Needs work
vipin.mittal18’s picture

Status: Needs work » Needs review
vipin.mittal18’s picture

Status: Needs review » Reviewed & tested by the community
vipin.mittal18’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.