Commit 6d8fcd6e authored by Gareth Alexander's avatar Gareth Alexander Committed by Paulo Henrique Cota Starling
Browse files

Issue #3266140 by the_g_bomb, paulocs, lucassc, joshua1234511: Create...

Issue #3266140 by the_g_bomb, paulocs, lucassc, joshua1234511: Create hook_update to remove duplicated entries in password_policy_history
parent 3c174aa7
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -165,3 +165,15 @@ function password_policy_update_8303() {
  $fieldConfig->setDescription('Control whether the user must reset their password. If the password has expired, this field is automatically checked after the execution of Cron.');
  $fieldConfig->save();
}

/**
 * Remove duplicate rows in the password_policy_history table.
 */
function password_policy_update_8304() {
  $moduleHandler = \Drupal::service('module_handler');
  if ($moduleHandler->moduleExists('password_policy_history')) {
    $table_name = 'password_policy_history';
    $query = \Drupal::database()->query('DELETE t1 FROM {' . $table_name . '} t1 INNER JOIN {' . $table_name . '} t2 WHERE t1.id < t2.id AND t1.pass_hash = t2.pass_hash AND t1.timestamp = t2.timestamp');
    $query->execute();
  }
}