Skip to content
This repository was archived by the owner on May 20, 2019. It is now read-only.

The user passed for async api referenced correct WebAPI user #22

Merged
merged 12 commits into from
Oct 10, 2018

Conversation

nuzil
Copy link

@nuzil nuzil commented May 18, 2018

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

Munkh-Ulzii Balidar added 2 commits May 12, 2018 13:28
…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
@magento-cicd2
Copy link

magento-cicd2 commented May 18, 2018

CLA assistant check
All committers have signed the CLA.

@magento-cicd2
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@vrann
Copy link
Contributor

vrann commented May 19, 2018

@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();

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.

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?

Copy link
Author

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:

  1. We will add prefixes to users, like "admin_ID, customer_ID" .....
  2. We will add new column to this table with user_type.

What do you think?

Copy link
Contributor

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

vrann
vrann previously requested changes Jun 15, 2018
@@ -95,6 +103,10 @@ public function publishMass($topicName, array $entitiesArray, $groupId = null, $
{
$bulkDescription = __('Topic %1', $topicName);

if ($userId == null) {
$userId = $this->userContext->getUserId();
Copy link
Contributor

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

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;

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.

@vkublytskyi vkublytskyi self-assigned this Sep 12, 2018
@@ -73,6 +79,7 @@ public function __construct(
BulkPublisherInterface $publisher,
MetadataPool $metadataPool,
ResourceConnection $resourceConnection,
UserContextInterface $userContext,
Copy link
Collaborator

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
Copy link
Collaborator

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)

@vkublytskyi vkublytskyi dismissed vrann’s stale review September 13, 2018 14:24

Requested changes are provided

 - applied backward compatibility policy to modified constructors
Copy link
Collaborator

@vkublytskyi vkublytskyi left a 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.

@vkublytskyi vkublytskyi changed the base branch from 2.3-develop to 2.3.0-release October 2, 2018 10:56
@@ -1,47 +1,50 @@
{
"magento_bulk": {
Copy link

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.
Copy link

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.

Copy link

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.

@vkublytskyi vkublytskyi force-pushed the comwrap-contribution-day branch 4 times, most recently from 5d2de54 to 918f8ae Compare October 8, 2018 15:41
@vkublytskyi vkublytskyi force-pushed the comwrap-contribution-day branch from 918f8ae to f708896 Compare October 8, 2018 20:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants