Skip to content

Commit 340c7ea

Browse files
ACPT-1194 ... part2
Now making all Collections reset after request... WOW!
1 parent f26fcf5 commit 340c7ea

File tree

10 files changed

+107
-1
lines changed

10 files changed

+107
-1
lines changed

app/code/Magento/Cms/Model/ResourceModel/Block/Collection.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ protected function _construct()
5858
$this->_map['fields']['block_id'] = 'main_table.block_id';
5959
}
6060

61+
/**
62+
* @inheritDoc
63+
*/
64+
public function _resetState(): void
65+
{
66+
parent::_resetState();
67+
$this->_map['fields']['store'] = 'store_table.store_id';
68+
$this->_map['fields']['block_id'] = 'main_table.block_id';
69+
}
70+
6171
/**
6272
* Returns pairs block_id - title
6373
*

app/code/Magento/Cms/Model/ResourceModel/Page/Collection.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ protected function _construct()
5151
$this->_map['fields']['store'] = 'store_table.store_id';
5252
}
5353

54+
/**
55+
* @inheritDoc
56+
*/
57+
public function _resetState(): void
58+
{
59+
parent::_resetState();
60+
$this->_map['fields']['page_id'] = 'main_table.page_id';
61+
$this->_map['fields']['store'] = 'store_table.store_id';
62+
}
63+
5464
/**
5565
* Set first store flag
5666
*

app/code/Magento/Customer/Model/ResourceModel/Address/Grid/Collection.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ public function __construct(
9494
);
9595
}
9696

97+
/**
98+
* @inheritDoc
99+
*/
100+
public function _resetState(): void
101+
{
102+
parent::_resetState();
103+
$this->_idFieldName = 'entity_id';
104+
}
105+
97106
/**
98107
* @inheritdoc
99108
*/

app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ protected function _construct()
6969
$this->_init(\Magento\Newsletter\Model\Queue::class, \Magento\Newsletter\Model\ResourceModel\Queue::class);
7070
}
7171

72+
/**
73+
* @inheritDoc
74+
*/
75+
public function _resetState(): void
76+
{
77+
parent::_resetState();
78+
$this->_map['fields']['queue_id'] = 'main_table.queue_id';
79+
}
80+
7281
/**
7382
* Joins templates information
7483
*

app/code/Magento/Newsletter/Model/ResourceModel/Subscriber/Collection.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@ protected function _construct()
107107
$this->_map['fields']['store_id'] = 'main_table.store_id';
108108
}
109109

110+
/**
111+
* @inheritDoc
112+
*/
113+
public function _resetState(): void
114+
{
115+
parent::_resetState();
116+
$this->_map['fields']['type'] = $this->getResource()->getConnection()->getCheckSql(
117+
'main_table.customer_id = 0',
118+
1,
119+
2
120+
);
121+
$this->_map['fields']['website_id'] = 'store.website_id';
122+
$this->_map['fields']['group_id'] = 'store.group_id';
123+
$this->_map['fields']['store_id'] = 'main_table.store_id';
124+
}
125+
110126
/**
111127
* Set loading mode subscribers by queue
112128
*

app/code/Magento/SalesRule/Model/ResourceModel/Rule/Collection.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ protected function _construct()
9696
$this->_map['fields']['rule_id'] = 'main_table.rule_id';
9797
}
9898

99+
/**
100+
* @inheritDoc
101+
*/
102+
public function _resetState(): void
103+
{
104+
parent::_resetState();
105+
$this->_map['fields']['rule_id'] = 'main_table.rule_id';
106+
}
107+
99108
/**
100109
* Map data for associated entities
101110
*

lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
namespace Magento\Framework\Api;
1010

1111
use Magento\Framework\Api\Search\FilterGroupBuilder;
12-
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1312

1413
/**
1514
* Builder for SearchCriteria Service Data Object

lib/internal/Magento/Framework/Data/Collection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,5 +933,12 @@ public function __wakeup()
933933
public function _resetState(): void
934934
{
935935
$this->clear();
936+
// TODO: Is it safe to move the following into clear() ?
937+
$this->_orders = [];
938+
$this->_filters = [];
939+
$this->_isFiltersRendered = false;
940+
$this->_curPage = 1;
941+
$this->_pageSize = false;
942+
$this->_flags = [];
936943
}
937944
}

lib/internal/Magento/Framework/Data/Collection/AbstractDb.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,22 @@ public function __construct(
119119
$this->_logger = $logger;
120120
}
121121

122+
/**
123+
* @inheritDoc
124+
*/
125+
public function _resetState(): void
126+
{
127+
parent::_resetState();
128+
$this->setConnection($this->_conn);
129+
$this->_idFieldName = null;
130+
$this->_bindParams = [];
131+
$this->_data = null;
132+
$this->map = null;
133+
$this->_fetchStmt = null;
134+
$this->_isOrdersRendered = false;
135+
$this->extensionAttributesJoinProcessor = null;
136+
}
137+
122138
/**
123139
* Get resource instance.
124140
*

lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,27 @@ protected function _construct() //phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
145145
{
146146
}
147147

148+
/**
149+
* @inheritDoc
150+
*/
151+
public function _resetState(): void
152+
{
153+
parent::_resetState();
154+
$this->_model = null;
155+
$this->_resourceModel = null;
156+
$this->_fieldsToSelect = null;
157+
$this->expressionFieldsToSelect = [];
158+
$this->_initialFieldsToSelect = null;
159+
$this->_fieldsToSelectChanged = false;
160+
$this->_joinedTables = [];
161+
$this->_mainTable = null;
162+
$this->_resetItemsDataChanged = false;
163+
$this->_eventPrefix = '';
164+
$this->_eventObject = '';
165+
$this->_construct();
166+
$this->_initSelect();
167+
}
168+
148169
/**
149170
* Retrieve main table
150171
*

0 commit comments

Comments
 (0)