Skip to content

Commit 0f39eae

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #13709: Changes static content deploy log levels verbosity (by @hostep) - magento-engcom/magento2ce#1187: #7515: Error when submit customer/account/editPost form and session expired (by @RomaKis) Fixed GitHub Issues: - #12404: Output of setup:static-content:deploy contains red color, should be a friendlier color (reported by @hostep) has been fixed in #13709 by @hostep in 2.2-develop branch Related commits: 1. d549014 2. 3733dea - #7515: Error when submit customer/account/editPost form and session expired (reported by @edelepine) has been fixed in magento-engcom/magento2ce#1187 by @RomaKis in 2.2-develop branch Related commits: 1. 9bb3dd3
2 parents dcd8bcb + b2129a9 commit 0f39eae

File tree

7 files changed

+71
-20
lines changed

7 files changed

+71
-20
lines changed

app/code/Magento/Captcha/Observer/CheckUserEditObserver.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,21 @@ public function execute(\Magento\Framework\Event\Observer $observer)
111111
)
112112
)) {
113113
$customerId = $this->customerSession->getCustomerId();
114-
$this->authentication->processAuthenticationFailure($customerId);
115-
if ($this->authentication->isLocked($customerId)) {
116-
$this->customerSession->logout();
117-
$this->customerSession->start();
118-
$message = __(
119-
'The account is locked. Please wait and try again or contact %1.',
120-
$this->scopeConfig->getValue('contact/email/recipient_email')
121-
);
122-
$this->messageManager->addError($message);
114+
if ($customerId) {
115+
$this->authentication->processAuthenticationFailure($customerId);
116+
if ($this->authentication->isLocked($customerId)) {
117+
$this->customerSession->logout();
118+
$this->customerSession->start();
119+
$message = __(
120+
'The account is locked. Please wait and try again or contact %1.',
121+
$this->scopeConfig->getValue('contact/email/recipient_email')
122+
);
123+
$this->messageManager->addError($message);
124+
}
125+
$this->messageManager->addError(__('Incorrect CAPTCHA'));
126+
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
127+
$this->redirect->redirect($controller->getResponse(), '*/*/edit');
123128
}
124-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
125-
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
126-
$this->redirect->redirect($controller->getResponse(), '*/*/edit');
127129
}
128130
}
129131

app/code/Magento/Captcha/Test/Unit/Observer/CheckUserEditObserverTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,53 @@ public function testExecute()
160160

161161
$this->observer->execute(new \Magento\Framework\Event\Observer(['controller_action' => $controller]));
162162
}
163+
164+
/**
165+
* @return void
166+
*/
167+
public function testExecuteWithCustomerIdNull()
168+
{
169+
$customerId = null;
170+
$captchaValue = 'some-value';
171+
172+
$captcha = $this->createMock(\Magento\Captcha\Model\DefaultModel::class);
173+
$captcha->expects($this->once())
174+
->method('isRequired')
175+
->willReturn(true);
176+
$captcha->expects($this->once())
177+
->method('isCorrect')
178+
->with($captchaValue)
179+
->willReturn(false);
180+
181+
$this->helperMock->expects($this->once())
182+
->method('getCaptcha')
183+
->with(\Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID)
184+
->willReturn($captcha);
185+
186+
$request = $this->createMock(\Magento\Framework\App\Request\Http::class);
187+
$request->expects($this->any())
188+
->method('getPost')
189+
->with(\Magento\Captcha\Helper\Data::INPUT_NAME_FIELD_VALUE, null)
190+
->willReturn([\Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID => $captchaValue]);
191+
192+
$controller = $this->createMock(\Magento\Framework\App\Action\Action::class);
193+
$controller->expects($this->any())->method('getRequest')->will($this->returnValue($request));
194+
195+
$this->captchaStringResolverMock->expects($this->once())
196+
->method('resolve')
197+
->with($request, \Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID)
198+
->willReturn($captchaValue);
199+
200+
$customerDataMock = $this->createMock(\Magento\Customer\Model\Data\Customer::class);
201+
202+
$this->customerSessionMock->expects($this->once())
203+
->method('getCustomerId')
204+
->willReturn($customerId);
205+
206+
$this->customerSessionMock->expects($this->atLeastOnce())
207+
->method('getCustomer')
208+
->willReturn($customerDataMock);
209+
210+
$this->observer->execute(new \Magento\Framework\Event\Observer(['controller_action' => $controller]));
211+
}
163212
}

app/code/Magento/Deploy/Console/ConsoleLogger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class ConsoleLogger extends AbstractLogger
8282
LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
8383
LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
8484
LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
85-
LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
86-
LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
85+
LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL,
86+
LogLevel::INFO => OutputInterface::VERBOSITY_VERBOSE,
8787
LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG
8888
];
8989

app/code/Magento/Deploy/Process/Queue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function process()
161161
foreach ($packages as $name => $packageJob) {
162162
$this->assertAndExecute($name, $packages, $packageJob);
163163
}
164-
$this->logger->notice('.');
164+
$this->logger->info('.');
165165
sleep(3);
166166
foreach ($this->inProgress as $name => $package) {
167167
if ($this->isDeployed($package)) {
@@ -233,7 +233,7 @@ private function awaitForAllProcesses()
233233
unset($this->inProgress[$name]);
234234
}
235235
}
236-
$this->logger->notice('.');
236+
$this->logger->info('.');
237237
sleep(5);
238238
}
239239
if ($this->isCanBeParalleled()) {

app/code/Magento/Deploy/Service/DeployPackage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ private function register(Package $package, PackageFile $file = null, $skipLoggi
271271
$this->deployStaticFile->writeTmpFile('info.json', $package->getPath(), json_encode($info));
272272

273273
if (!$skipLogging) {
274-
$this->logger->notice($logMessage);
274+
$this->logger->info($logMessage);
275275
}
276276
}
277277
}

setup/src/Magento/Setup/Console/Command/DeployStaticContentCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
127127

128128
$logger = $this->consoleLoggerFactory->getLogger($output, $verbose);
129129
if (!$refreshOnly) {
130-
$logger->alert(PHP_EOL . "Deploy using {$options[Options::STRATEGY]} strategy");
130+
$logger->notice(PHP_EOL . "Deploy using {$options[Options::STRATEGY]} strategy");
131131
}
132132

133133
$this->mockCache();
@@ -140,7 +140,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
140140
$deployService->deploy($options);
141141

142142
if (!$refreshOnly) {
143-
$logger->alert(PHP_EOL . "Execution time: " . (microtime(true) - $time));
143+
$logger->notice(PHP_EOL . "Execution time: " . (microtime(true) - $time));
144144
}
145145

146146
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;

setup/src/Magento/Setup/Test/Unit/Console/Command/DeployStaticContentCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testExecute($input)
102102

103103
$this->consoleLoggerFactory->expects($this->once())
104104
->method('getLogger')->willReturn($this->logger);
105-
$this->logger->expects($this->exactly(2))->method('alert');
105+
$this->logger->expects($this->exactly(2))->method('notice');
106106

107107
$this->objectManager->expects($this->once())->method('create')->willReturn($this->deployService);
108108
$this->deployService->expects($this->once())->method('deploy');

0 commit comments

Comments
 (0)