Skip to content

Commit 0bb4f53

Browse files
ACPT-1194-part2
Reset Validators DON'T reset EAV's Attribute/Collection
1 parent 23be3be commit 0bb4f53

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

app/code/Magento/Eav/Model/ResourceModel/Attribute/Collection.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ public function __construct(
6464
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $eavConfig, $connection, $resource);
6565
}
6666

67+
/**
68+
* @inheritDoc
69+
*/
70+
public function _resetState(): void
71+
{
72+
/* Note: because Eav attribute loading takes significant performance,
73+
we are not resetting it like other collections. */
74+
}
75+
6776
/**
6877
* Default attribute entity type code
6978
*

app/code/Magento/Eav/Model/Validator/Attribute/Data.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ public function __construct(
6969
$this->ignoredAttributesByTypesList = $ignoredAttributesByTypesList;
7070
}
7171

72+
/**
73+
* @inheritDoc
74+
*/
75+
public function _resetState(): void
76+
{
77+
parent::_resetState();
78+
$this->_attributes = [];
79+
$this->allowedAttributesList = [];
80+
$this->deniedAttributesList = [];
81+
$this->_data = [];
82+
}
83+
7284
/**
7385
* Set list of attributes for validation in isValid method.
7486
*

lib/internal/Magento/Framework/Validator/AbstractValidator.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Framework\Validator;
77

88
use Laminas\Validator\Translator\TranslatorInterface;
9+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
910

1011
/**
1112
* Abstract validator class.
@@ -14,7 +15,7 @@
1415
* @api
1516
* @since 100.0.2
1617
*/
17-
abstract class AbstractValidator implements ValidatorInterface
18+
abstract class AbstractValidator implements ValidatorInterface, ResetAfterRequestInterface
1819
{
1920
/**
2021
* @var TranslatorInterface|null
@@ -31,6 +32,15 @@ abstract class AbstractValidator implements ValidatorInterface
3132
*/
3233
protected $_messages = [];
3334

35+
/**
36+
* @inheritDoc
37+
*/
38+
public function _resetState(): void
39+
{
40+
$this->_translator = null;
41+
$this->_messages = [];
42+
}
43+
3444
/**
3545
* Set default translator instance
3646
*

0 commit comments

Comments
 (0)