From e373e0c3ca60e8b29738b1f1c304c4a9a93d60b8 Mon Sep 17 00:00:00 2001 From: Danny Nimmo Date: Tue, 23 Jul 2024 14:08:40 +1200 Subject: [PATCH] Fix "Area code is already set" error --- Console/GenerateEncryptionKey.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Console/GenerateEncryptionKey.php b/Console/GenerateEncryptionKey.php index 6620f1a..421aeb6 100644 --- a/Console/GenerateEncryptionKey.php +++ b/Console/GenerateEncryptionKey.php @@ -105,7 +105,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int * * @see \Magento\EncryptionKey\Controller\Adminhtml\Crypt\Key\Save::execute() */ - $this->state->setAreaCode('adminhtml'); + try { + $this->state->setAreaCode('adminhtml'); + } catch (\Magento\Framework\Exception\LocalizedException $exception) { + // Area code is already set + } $this->emulation->startEnvironmentEmulation(0, 'adminhtml'); $output->writeln('Generating a new encryption key using the magento core class'); $this->changeEncryptionKey->setOutput($output);