Skip to content

Commit a1fad2b

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Accepted Community Pull Requests: - #26769: Fix return type in ResetAttemptForFrontendObserver and ResetAttemptForBackendObserver (by @karyna-tsymbal-atwix) - #26712: Unit test for \Magento\Captcha\Observer\CheckUserForgotPasswordBackendObserver (by @karyna-tsymbal-atwix) - #26857: Issue/26843: Fix es_US Spanish (United States ) Locale is not support� (by @vincent-le89) - #26839: Unit test for \Magento\MediaGallery\Plugin\Wysiwyg\Images\Storage (by @karyna-tsymbal-atwix) - #26844: Unit Tests for observers from Magento_Reports (by @karyna-tsymbal-atwix) - #26688: Use '===' operator to check if file was written. (by @vovayatsyuk) - #26846: magento/magento2#: GraphQL. setPaymentMethodOnCart mutation. Extend list of required parameters for testSetPaymentMethodWithoutRequiredParameters (by @atwixfirster) - #24612: Fix for the issue #24547 Magento\Customer\Model\Account\Redirect::setRedirectCookie() not properly working (by @sashas777) - #26768: Marginal space validation (by @ajithkumar-maragathavel) - #26835: Unit test for Magento\Downloadable\Model\Sample\DeleteHandler (by @karyna-tsymbal-atwix) - #26398: Move additional dependencies from private getters to constructor - Magento_Captcha (by @Bartlomiejsz) - #26659: [26054-Do not duplicate SEO meta data when duplicating a product] (by @dasharath-wagento) - #26317: #26314: fixed logic for updating map price for selected swatch (by @sergiy-v) Fixed GitHub Issues: - #26843: es_US Spanish (United States ) Locale is not supported in Magento 2.3.4 (reported by @karthi6116) has been fixed in #26857 by @vincent-le89 in 2.4-develop branch Related commits: 1. bab4fb6 2. fb71138 3. 2b1bce5 - #24547: Magento\Customer\Model\Account\Redirect::setRedirectCookie() not properly working (reported by @nikoskip) has been fixed in #24612 by @sashas777 in 2.4-develop branch Related commits: 1. a15f335 2. 664056f 3. 5188efd 4. 3cf8f22 5. 7597003 6. 9413892 7. 9f2bbc2 8. bfa636f 9. 6446aed 10. 162ca60 11. 16da706 12. 2c24ef9 13. a514803 14. bfeadd7 15. cd5ef3c 16. dc416a9 17. 41ce59e 18. f021f1e 19. 511e16a - #26054: Do not duplicate SEO meta data when duplicating a product (reported by @Zyles) has been fixed in #26659 by @dasharath-wagento in 2.4-develop branch Related commits: 1. 1f96b87 2. 89b0a9d 3. 99383fc 4. 2d19477 5. 5aea4ac 6. dbf3924 - #26240: Minimum Advertised Price doesn't change for selected swatch option for configurable product (reported by @sergiy-v) has been fixed in #26317 by @sergiy-v in 2.4-develop branch Related commits: 1. b3abb06 2. 9d9086f 3. c12ca77 4. 992e3d1 5. df37523 6. 824ef9f - #26314: Minimum Advertised Prices duplicates for all configurable products with price from selected swatch (reported by @sergiy-v) has been fixed in #26317 by @sergiy-v in 2.4-develop branch Related commits: 1. b3abb06 2. 9d9086f 3. c12ca77 4. 992e3d1 5. df37523 6. 824ef9f
2 parents cde4f67 + abc8d10 commit a1fad2b

File tree

29 files changed

+1593
-328
lines changed

29 files changed

+1593
-328
lines changed

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

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,41 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Captcha\Observer;
79

10+
use Magento\Captcha\Helper\Data;
11+
use Magento\Framework\App\Action\Action;
12+
use Magento\Framework\App\ActionFlag;
13+
use Magento\Framework\App\Response\RedirectInterface;
14+
use Magento\Framework\Event\Observer;
815
use Magento\Framework\Event\ObserverInterface;
916
use Magento\Framework\App\Request\DataPersistorInterface;
10-
use Magento\Framework\App\ObjectManager;
17+
use Magento\Framework\Message\ManagerInterface;
1118

1219
/**
13-
* Class CheckContactUsFormObserver
20+
* Check captcha on contact us form submit observer.
1421
*/
1522
class CheckContactUsFormObserver implements ObserverInterface
1623
{
1724
/**
18-
* @var \Magento\Captcha\Helper\Data
25+
* @var Data
1926
*/
2027
protected $_helper;
2128

2229
/**
23-
* @var \Magento\Framework\App\ActionFlag
30+
* @var ActionFlag
2431
*/
2532
protected $_actionFlag;
2633

2734
/**
28-
* @var \Magento\Framework\Message\ManagerInterface
35+
* @var ManagerInterface
2936
*/
3037
protected $messageManager;
3138

3239
/**
33-
* @var \Magento\Framework\App\Response\RedirectInterface
40+
* @var RedirectInterface
3441
*/
3542
protected $redirect;
3643

@@ -45,60 +52,48 @@ class CheckContactUsFormObserver implements ObserverInterface
4552
private $dataPersistor;
4653

4754
/**
48-
* @param \Magento\Captcha\Helper\Data $helper
49-
* @param \Magento\Framework\App\ActionFlag $actionFlag
50-
* @param \Magento\Framework\Message\ManagerInterface $messageManager
51-
* @param \Magento\Framework\App\Response\RedirectInterface $redirect
55+
* @param Data $helper
56+
* @param ActionFlag $actionFlag
57+
* @param ManagerInterface $messageManager
58+
* @param RedirectInterface $redirect
5259
* @param CaptchaStringResolver $captchaStringResolver
60+
* @param DataPersistorInterface $dataPersistor
5361
*/
5462
public function __construct(
55-
\Magento\Captcha\Helper\Data $helper,
56-
\Magento\Framework\App\ActionFlag $actionFlag,
57-
\Magento\Framework\Message\ManagerInterface $messageManager,
58-
\Magento\Framework\App\Response\RedirectInterface $redirect,
59-
CaptchaStringResolver $captchaStringResolver
63+
Data $helper,
64+
ActionFlag $actionFlag,
65+
ManagerInterface $messageManager,
66+
RedirectInterface $redirect,
67+
CaptchaStringResolver $captchaStringResolver,
68+
DataPersistorInterface $dataPersistor
6069
) {
6170
$this->_helper = $helper;
6271
$this->_actionFlag = $actionFlag;
6372
$this->messageManager = $messageManager;
6473
$this->redirect = $redirect;
6574
$this->captchaStringResolver = $captchaStringResolver;
75+
$this->dataPersistor = $dataPersistor;
6676
}
6777

6878
/**
6979
* Check CAPTCHA on Contact Us page
7080
*
71-
* @param \Magento\Framework\Event\Observer $observer
81+
* @param Observer $observer
7282
* @return void
7383
*/
74-
public function execute(\Magento\Framework\Event\Observer $observer)
84+
public function execute(Observer $observer)
7585
{
7686
$formId = 'contact_us';
7787
$captcha = $this->_helper->getCaptcha($formId);
7888
if ($captcha->isRequired()) {
79-
/** @var \Magento\Framework\App\Action\Action $controller */
89+
/** @var Action $controller */
8090
$controller = $observer->getControllerAction();
8191
if (!$captcha->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
8292
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA.'));
83-
$this->getDataPersistor()->set($formId, $controller->getRequest()->getPostValue());
84-
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
93+
$this->dataPersistor->set($formId, $controller->getRequest()->getPostValue());
94+
$this->_actionFlag->set('', Action::FLAG_NO_DISPATCH, true);
8595
$this->redirect->redirect($controller->getResponse(), 'contact/index/index');
8696
}
8797
}
8898
}
89-
90-
/**
91-
* Get Data Persistor
92-
*
93-
* @return DataPersistorInterface
94-
*/
95-
private function getDataPersistor()
96-
{
97-
if ($this->dataPersistor === null) {
98-
$this->dataPersistor = ObjectManager::getInstance()
99-
->get(DataPersistorInterface::class);
100-
}
101-
102-
return $this->dataPersistor;
103-
}
10499
}

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,39 @@
55
*/
66
namespace Magento\Captcha\Observer;
77

8+
use Magento\Captcha\Model\ResourceModel\Log;
9+
use Magento\Captcha\Model\ResourceModel\LogFactory;
10+
use Magento\Framework\Event\Observer;
811
use Magento\Framework\Event\ObserverInterface;
12+
use Magento\Framework\Exception\LocalizedException;
913

14+
/**
15+
* Reset captcha attempts for Backend
16+
*/
1017
class ResetAttemptForBackendObserver implements ObserverInterface
1118
{
1219
/**
13-
* @var \Magento\Captcha\Model\ResourceModel\LogFactory
20+
* @var LogFactory
1421
*/
1522
public $resLogFactory;
1623

1724
/**
18-
* @param \Magento\Captcha\Model\ResourceModel\LogFactory $resLogFactory
25+
* @param LogFactory $resLogFactory
1926
*/
2027
public function __construct(
21-
\Magento\Captcha\Model\ResourceModel\LogFactory $resLogFactory
28+
LogFactory $resLogFactory
2229
) {
2330
$this->resLogFactory = $resLogFactory;
2431
}
2532

2633
/**
2734
* Reset Attempts For Backend
2835
*
29-
* @param \Magento\Framework\Event\Observer $observer
30-
* @return \Magento\Captcha\Observer\ResetAttemptForBackendObserver
36+
* @param Observer $observer
37+
* @return Log
38+
* @throws LocalizedException
3139
*/
32-
public function execute(\Magento\Framework\Event\Observer $observer)
40+
public function execute(Observer $observer)
3341
{
3442
return $this->resLogFactory->create()->deleteUserAttempts($observer->getUser()->getUsername());
3543
}

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,42 @@
55
*/
66
namespace Magento\Captcha\Observer;
77

8+
use Magento\Captcha\Model\ResourceModel\Log;
9+
use Magento\Captcha\Model\ResourceModel\LogFactory;
10+
use Magento\Customer\Model\Customer;
11+
use Magento\Framework\Event\Observer;
812
use Magento\Framework\Event\ObserverInterface;
13+
use Magento\Framework\Exception\LocalizedException;
914

15+
/**
16+
* Reset captcha attempts for Frontend
17+
*/
1018
class ResetAttemptForFrontendObserver implements ObserverInterface
1119
{
1220
/**
13-
* @var \Magento\Captcha\Model\ResourceModel\LogFactory
21+
* @var LogFactory
1422
*/
1523
public $resLogFactory;
1624

1725
/**
18-
* @param \Magento\Captcha\Model\ResourceModel\LogFactory $resLogFactory
26+
* @param LogFactory $resLogFactory
1927
*/
2028
public function __construct(
21-
\Magento\Captcha\Model\ResourceModel\LogFactory $resLogFactory
29+
LogFactory $resLogFactory
2230
) {
2331
$this->resLogFactory = $resLogFactory;
2432
}
2533

2634
/**
2735
* Reset Attempts For Frontend
2836
*
29-
* @param \Magento\Framework\Event\Observer $observer
30-
* @return \Magento\Captcha\Observer\ResetAttemptForFrontendObserver
37+
* @param Observer $observer
38+
* @return Log
39+
* @throws LocalizedException
3140
*/
32-
public function execute(\Magento\Framework\Event\Observer $observer)
41+
public function execute(Observer $observer)
3342
{
34-
/** @var \Magento\Customer\Model\Customer $model */
43+
/** @var Customer $model */
3544
$model = $observer->getModel();
3645

3746
return $this->resLogFactory->create()->deleteUserAttempts($model->getEmail());

0 commit comments

Comments
 (0)