Skip to content

Commit 2621729

Browse files
committed
MC-34522: Two near-simultaneous product imports interfere with each other
- Check table name before adding user_id constraint
1 parent 5f9668f commit 2621729

File tree

1 file changed

+14
-5
lines changed
  • app/code/Magento/ImportExport/Model/ResourceModel/Import

1 file changed

+14
-5
lines changed

app/code/Magento/ImportExport/Model/ResourceModel/Import/Data.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,11 @@ public function saveBunch($entity, $behavior, array $data)
200200
*/
201201
private function prepareSelect(Select $select): Select
202202
{
203-
// user_id is NULL part is for backward compatibility
204-
$select->where('user_id=? OR user_id is NULL', $this->getCurrentUserId() ?? self::DEFAULT_USER_ID);
203+
// check if the table has not been overridden for backward compatibility
204+
if ($this->getMainTable() === $this->getTable('importexport_importdata')) {
205+
// user_id is NULL part is for backward compatibility
206+
$select->where('user_id=? OR user_id is NULL', $this->getCurrentUserId() ?? self::DEFAULT_USER_ID);
207+
}
205208

206209
return $select;
207210
}
@@ -214,7 +217,10 @@ private function prepareSelect(Select $select): Select
214217
*/
215218
private function prepareInsert(array $data): array
216219
{
217-
$data['user_id'] = $this->getCurrentUserId() ?? self::DEFAULT_USER_ID;
220+
// check if the table has not been overridden for backward compatibility
221+
if ($this->getMainTable() === $this->getTable('importexport_importdata')) {
222+
$data['user_id'] = $this->getCurrentUserId() ?? self::DEFAULT_USER_ID;
223+
}
218224

219225
return $data;
220226
}
@@ -227,8 +233,11 @@ private function prepareInsert(array $data): array
227233
*/
228234
private function prepareDelete(array $where): array
229235
{
230-
// user_id is NULL part is for backward compatibility
231-
$where['user_id=? OR user_id is NULL'] = $this->getCurrentUserId() ?? self::DEFAULT_USER_ID;
236+
// check if the table has not been overridden for backward compatibility
237+
if ($this->getMainTable() === $this->getTable('importexport_importdata')) {
238+
// user_id is NULL part is for backward compatibility
239+
$where['user_id=? OR user_id is NULL'] = $this->getCurrentUserId() ?? self::DEFAULT_USER_ID;
240+
}
232241

233242
return $where;
234243
}

0 commit comments

Comments
 (0)