-
Notifications
You must be signed in to change notification settings - Fork 17
The user passed for async api referenced correct WebAPI user #22
Conversation
…ass the Web API user id taken from the context object to MassScheduler
…ass the Web API user id taken from the context object to MassScheduler
|
@nuzil @anvasiliev can you please fix travis and sign CLA |
@@ -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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @paliarush , @vrann
We though about 2 possible solutions, maybe we have to discuss it separately:
- We will add prefixes to users, like "admin_ID, customer_ID" .....
- We will add new column to this table with user_type.
What do you think?
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.
@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
@@ -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 comment
The 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
|
||
/** | ||
* Set user type | ||
* @param int $operationCount |
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.
Looks like copy-paste
@@ -108,6 +108,7 @@ public function testScheduleBulk() | |||
$bulkUuid = 'bulk-001'; | |||
$description = 'Bulk summary description...'; | |||
$userId = 1; | |||
$userType = 2; |
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.
User types are defined in \Magento\Authorization\Model\UserContextInterface
as constants. Please use one of those constants to make code cleaner.
@@ -73,6 +79,7 @@ public function __construct( | |||
BulkPublisherInterface $publisher, | |||
MetadataPool $metadataPool, | |||
ResourceConnection $resourceConnection, | |||
UserContextInterface $userContext, |
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)
@@ -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 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 (as optional)
- applied backward compatibility policy to modified constructors
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.
Before merge following issues should be resolved:
- The class MassSchedule has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
- During upgrade foreign key
MAGENTO_BULK_USER_ID_ADMIN_USER_USER_ID
is not dropped for Magento Commerce installation.
@@ -1,47 +1,50 @@ | |||
{ | |||
"magento_bulk": { |
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.
Please keep 4 spaces intendation for whitelists, changes are very hard to read.
@@ -177,7 +182,9 @@ private function calculateDiff(ElementInterface $declaredTable, ElementInterface | |||
$declaredElements = $declaredTable->getElementsByType($elementType); | |||
|
|||
if ($elementType === self::INDEX_DIFF_TYPE) { | |||
$generatedElements = $this->excludeAutoIndexes($generatedTable, $generatedElements); | |||
// We should exclude from generated indexes only these auto indexes that correspond to | |||
// declared constraint. If constraint is not declared we should clean up index created for it. |
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.
What is the purpose of this change?
It causes a case when autogenerated index will be implicitly removed from declaration so removing FK with preserving index for performance purposes won't work.
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.
If you need to remove index use declaration with 'disable="1"' attribute.
5d2de54
to
918f8ae
Compare
918f8ae
to
f708896
Compare
https://app.zenhub.com/workspace/o/magento/bulk-api-ce/issues/14
Drop foreign key referencing admin_user table from bulk operations. Pass the Web API user id taken from the context object to MassScheduler