From 022d4309a32ce36d1dce786acf70cfef0c8585ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rn=20Fauske?= <jorn@ramsalt.com> Date: Mon, 17 Mar 2025 23:15:24 +0100 Subject: [PATCH] Issue #3512046 Update crypt method names stored in cryptsetting. After upgrading to drd 4.1.7, the cryptsetting field in the drd_domain table contain keys with names that need updating. If not, $passord in Drupal\drd\Crypt\Method\<MethodClass> will be empty. That in turn make the 'args'-field in BaseEntityRemote::remoteRequest() empty, which cause communication with the a specific drd_agent to fail. --- drd.install | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drd.install b/drd.install index e2ee285..e0a1271 100644 --- a/drd.install +++ b/drd.install @@ -177,3 +177,36 @@ function drd_update_8008(): void { ->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(); + } + } + } +} -- GitLab