-
Notifications
You must be signed in to change notification settings - Fork 17
The user passed for async api referenced correct WebAPI user #22
Changes from 8 commits
0748ada
55fb636
7bf456a
9d112a6
9e56563
9724202
73d1e38
614ed8a
1acda9b
3d1e389
3aa2955
f708896
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
use Magento\Framework\Exception\BulkException; | ||
use Psr\Log\LoggerInterface; | ||
use Magento\AsynchronousOperations\Model\ResourceModel\Operation\OperationRepository; | ||
use Magento\Authorization\Model\UserContextInterface; | ||
|
||
/** | ||
* Class MassSchedule used for adding multiple entities as Operations to Bulk Management with the status tracking | ||
|
@@ -54,6 +55,11 @@ class MassSchedule | |
*/ | ||
private $operationRepository; | ||
|
||
/** | ||
* @var \Magento\Authorization\Model\UserContextInterface | ||
*/ | ||
private $userContext; | ||
|
||
/** | ||
* Initialize dependencies. | ||
* | ||
|
@@ -70,14 +76,16 @@ public function __construct( | |
AsyncResponseInterfaceFactory $asyncResponseFactory, | ||
BulkManagementInterface $bulkManagement, | ||
LoggerInterface $logger, | ||
OperationRepository $operationRepository | ||
OperationRepository $operationRepository, | ||
UserContextInterface $userContext | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This constructor exists in Magento Commerce 2.2 so new parameters should be added corresponding to backward compatibility policies (as optional) |
||
) { | ||
$this->identityService = $identityService; | ||
$this->itemStatusInterfaceFactory = $itemStatusInterfaceFactory; | ||
$this->asyncResponseFactory = $asyncResponseFactory; | ||
$this->bulkManagement = $bulkManagement; | ||
$this->logger = $logger; | ||
$this->operationRepository = $operationRepository; | ||
$this->userContext = $userContext; | ||
} | ||
|
||
/** | ||
|
@@ -95,6 +103,10 @@ public function publishMass($topicName, array $entitiesArray, $groupId = null, $ | |
{ | ||
$bulkDescription = __('Topic %1', $topicName); | ||
|
||
if ($userId == null) { | ||
$userId = $this->userContext->getUserId(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User ID is not unique identifier and should be used in conjunction with user type. There could be integration, admin and customer with the same ID. I believe bulk operation could at least be scheduled by the admin or integration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are right the user ID is not unique. @anvasiliev @nuzil How do you think if we save the user type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @paliarush , @vrann
What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @munkhulzii @nuzil it would be a cleaner solution if we add another column, with the default value set to the admin. Otherwise it will be backward incompatible with the rest of the system |
||
} | ||
|
||
if ($groupId == null) { | ||
$groupId = $this->identityService->generateId(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
{ | ||
"magento_bulk": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep 4 spaces intendation for whitelists, changes are very hard to read. |
||
"column": { | ||
"id": true, | ||
"uuid": true, | ||
"user_id": true, | ||
"description": true, | ||
"operation_count": true, | ||
"start_time": true | ||
}, | ||
"constraint": { | ||
"PRIMARY": true, | ||
"MAGENTO_BULK_USER_ID_ADMIN_USER_USER_ID": true, | ||
"MAGENTO_BULK_UUID": true | ||
} | ||
"magento_bulk": { | ||
"column": { | ||
"id": true, | ||
"uuid": true, | ||
"user_id": true, | ||
"user_type": true, | ||
"description": true, | ||
"operation_count": true, | ||
"start_time": true | ||
}, | ||
"magento_operation": { | ||
"column": { | ||
"id": true, | ||
"bulk_uuid": true, | ||
"topic_name": true, | ||
"serialized_data": true, | ||
"result_serialized_data": true, | ||
"status": true, | ||
"error_code": true, | ||
"result_message": true | ||
}, | ||
"index": { | ||
"MAGENTO_OPERATION_BULK_UUID_ERROR_CODE": true | ||
}, | ||
"constraint": { | ||
"PRIMARY": true, | ||
"MAGENTO_OPERATION_BULK_UUID_MAGENTO_BULK_UUID": true | ||
} | ||
"constraint": { | ||
"PRIMARY": true, | ||
"MAGENTO_BULK_UUID": true | ||
} | ||
}, | ||
"magento_operation": { | ||
"column": { | ||
"id": true, | ||
"bulk_uuid": true, | ||
"topic_name": true, | ||
"serialized_data": true, | ||
"result_serialized_data": true, | ||
"status": true, | ||
"error_code": true, | ||
"result_message": true | ||
}, | ||
"index": { | ||
"MAGENTO_OPERATION_BULK_UUID_ERROR_CODE": true | ||
}, | ||
"constraint": { | ||
"PRIMARY": true, | ||
"MAGENTO_OPERATION_BULK_UUID_MAGENTO_BULK_UUID": true | ||
} | ||
}, | ||
"magento_acknowledged_bulk": { | ||
"column": { | ||
"id": true, | ||
"bulk_uuid": true | ||
}, | ||
"magento_acknowledged_bulk": { | ||
"column": { | ||
"id": true, | ||
"bulk_uuid": true | ||
}, | ||
"constraint": { | ||
"PRIMARY": true, | ||
"MAGENTO_ACKNOWLEDGED_BULK_BULK_UUID_MAGENTO_BULK_UUID": true, | ||
"MAGENTO_ACKNOWLEDGED_BULK_BULK_UUID": true | ||
} | ||
"constraint": { | ||
"PRIMARY": true, | ||
"MAGENTO_ACKNOWLEDGED_BULK_BULK_UUID_MAGENTO_BULK_UUID": true, | ||
"MAGENTO_ACKNOWLEDGED_BULK_BULK_UUID": true | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constructor exists in Magento Commerce 2.2 so new parameters should be added corresponding to backward compatibility policies (at the end as optional)