Skip to content
Snippets Groups Projects

Issue #3512046 Update crypt method names stored in cryptsetting.

1 file
+ 33
0
Compare changes
  • Side-by-side
  • Inline
+ 33
0
@@ -177,3 +177,36 @@ function drd_update_8008(): void {
@@ -177,3 +177,36 @@ function drd_update_8008(): void {
->execute();
->execute();
}
}
}
}
 
 
/**
 
* Update crypt class names stored as keys in the cryptsetting field.
 
*/
 
function drd_update_8009(): void {
 
$domains = \Drupal::entityTypeManager()->getStorage('drd_domain')->loadMultiple();
 
$encryptService = \Drupal::service('drd.encrypt');
 
$methods = [
 
'MCrypt' => 'Mcrypt',
 
'OpenSSL' => 'OpenSsl',
 
'TLS' => 'Tls',
 
];
 
 
/** @var \Drupal\drd\Entity\DomainInterface $domain */
 
foreach ($domains as $domain) {
 
foreach ($methods as $old => $new) {
 
$cryptSetting = $domain->getCryptSetting($old);
 
 
if (count($cryptSetting) > 0) {
 
// Values in $cryptSetting were decrypted above.
 
$encryptService->encrypt($cryptSetting);
 
 
// Need to add method "key" before saving the new cryptsetting array.
 
$newCryptSetting = [
 
$new => $cryptSetting,
 
];
 
 
$domain->set('cryptsetting', $newCryptSetting);
 
$domain->save();
 
}
 
}
 
}
 
}
Loading