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

Commit 8a7f23e

Browse files
authored
Merge pull request #3306 from magento-borg/2.3.0-release-sync2
Sync2 2.3.0 with 2.3-develop
2 parents 708017a + f4d0420 commit 8a7f23e

File tree

171 files changed

+2899
-5559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+2899
-5559
lines changed

app/code/Magento/Analytics/Test/Mftf/Data/UserData.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
1111
<entity name="adminNoReport" type="user">
1212
<data key="username" unique="suffix">noreport</data>
1313
<data key="firstname">No</data>
@@ -18,7 +18,7 @@
1818
<data key="interface_local">en_US</data>
1919
<data key="is_active">true</data>
2020
<data key="current_password">123123q</data>
21-
</entity>
21+
</entity>
2222
<entity name="restrictedWebUser" type="user">
2323
<data key="username" unique="suffix">restrictedWebUser</data>
2424
<data key="firstname">restricted</data>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
9+
<section name="AdminConfigSection">
10+
<element name="advancedReportingMenuItem" type="text" selector="//*[@id='system_config_tabs']/div[1]//span[text()='Advanced Reporting']"/>
11+
<element name="advancedReportingService" type="select" selector="#analytics_general_enabled"/>
12+
<element name="advancedReportingServiceLabel" type="text" selector="#row_analytics_general_enabled>td.label>label>span"/>
13+
<element name="advancedReportingServiceStatus" type="text" selector="#row_analytics_general_enabled>td.value>p>span"/>
14+
<element name="advancedReportingIndustry" type="select" selector="#analytics_general_vertical"/>
15+
<element name="advancedReportingIndustryLabel" type="text" selector=".config-vertical-label>label>span"/>
16+
<element name="advancedReportingHour" type="select" selector="#row_analytics_general_collection_time>td:nth-child(2)>select:nth-child(2)"/>
17+
<element name="advancedReportingMinute" type="select" selector="#row_analytics_general_collection_time>td:nth-child(2)>select:nth-child(3)"/>
18+
<element name="advancedReportingSeconds" type="select" selector="#row_analytics_general_collection_time>td:nth-child(2)>select:nth-child(4)"/>
19+
<element name="advancedReportingBlankIndustryError" type="text" selector=".message-error>div"/>
20+
<element name="advancedReportingSuccessMessage" type="text" selector=".message-success>div"/>
21+
</section>
22+
</sections>

app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationEnableDisableAnalyticsTest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<severity value="MAJOR"/>
1717
<testCaseId value="MAGETWO-66465"/>
1818
<group value="analytics"/>
19-
<skip>
20-
<issueId value="MAGETWO-90659"/>
21-
</skip>
2219
</annotations>
2320
<after>
2421
<amOnPage stepKey="amOnLogoutPage" url="admin/admin/auth/logout/"/>

app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationIndustryTest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<severity value="MAJOR"/>
1818
<testCaseId value="MAGETWO-63898"/>
1919
<group value="analytics"/>
20-
<skip>
21-
<issueId value="MAGETWO-90659"/>
22-
</skip>
2320
</annotations>
2421

2522
<actionGroup ref="LoginActionGroup" stepKey="loginAsAdmin"/>

app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationPermissionTest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MAGETWO-82648"/>
1919
<group value="analytics"/>
20-
<skip>
21-
<issueId value="MAGETWO-90659"/>
22-
</skip>
2320
</annotations>
2421
<before>
2522
<createData stepKey="noReportUserRole" entity="adminNoReportRole"/>

app/code/Magento/AsynchronousOperations/Api/Data/BulkSummaryInterface.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
interface BulkSummaryInterface extends \Magento\Framework\Bulk\BulkSummaryInterface
1515
{
16+
const USER_TYPE = 'user_type';
17+
1618
/**
1719
* Retrieve existing extension attributes object.
1820
*
@@ -31,4 +33,19 @@ public function getExtensionAttributes();
3133
public function setExtensionAttributes(
3234
\Magento\AsynchronousOperations\Api\Data\BulkSummaryExtensionInterface $extensionAttributes
3335
);
36+
37+
/**
38+
* Get user type
39+
*
40+
* @return int
41+
*/
42+
public function getUserType();
43+
44+
/**
45+
* Set user type
46+
*
47+
* @param int $userType
48+
* @return $this
49+
*/
50+
public function setUserType($userType);
3451
}

app/code/Magento/AsynchronousOperations/Model/BulkManagement.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\AsynchronousOperations\Model;
77

8+
use Magento\Framework\App\ObjectManager;
89
use Magento\Framework\App\ResourceConnection;
910
use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface;
1011
use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterfaceFactory;
@@ -13,6 +14,7 @@
1314
use Magento\Framework\EntityManager\EntityManager;
1415
use Magento\Framework\EntityManager\MetadataPool;
1516
use Magento\AsynchronousOperations\Model\ResourceModel\Operation\CollectionFactory;
17+
use Magento\Authorization\Model\UserContextInterface;
1618

1719
/**
1820
* Class BulkManagement
@@ -51,6 +53,11 @@ class BulkManagement implements \Magento\Framework\Bulk\BulkManagementInterface
5153
*/
5254
private $resourceConnection;
5355

56+
/**
57+
* @var \Magento\Authorization\Model\UserContextInterface
58+
*/
59+
private $userContext;
60+
5461
/**
5562
* @var \Psr\Log\LoggerInterface
5663
*/
@@ -65,6 +72,7 @@ class BulkManagement implements \Magento\Framework\Bulk\BulkManagementInterface
6572
* @param MetadataPool $metadataPool
6673
* @param ResourceConnection $resourceConnection
6774
* @param \Psr\Log\LoggerInterface $logger
75+
* @param UserContextInterface $userContext
6876
*/
6977
public function __construct(
7078
EntityManager $entityManager,
@@ -73,7 +81,8 @@ public function __construct(
7381
BulkPublisherInterface $publisher,
7482
MetadataPool $metadataPool,
7583
ResourceConnection $resourceConnection,
76-
\Psr\Log\LoggerInterface $logger
84+
\Psr\Log\LoggerInterface $logger,
85+
UserContextInterface $userContext = null
7786
) {
7887
$this->entityManager = $entityManager;
7988
$this->bulkSummaryFactory= $bulkSummaryFactory;
@@ -82,6 +91,7 @@ public function __construct(
8291
$this->resourceConnection = $resourceConnection;
8392
$this->publisher = $publisher;
8493
$this->logger = $logger;
94+
$this->userContext = $userContext ?: ObjectManager::getInstance()->get(UserContextInterface::class);
8595
}
8696

8797
/**
@@ -93,13 +103,18 @@ public function scheduleBulk($bulkUuid, array $operations, $description, $userId
93103
$connection = $this->resourceConnection->getConnectionByName($metadata->getEntityConnectionName());
94104
// save bulk summary and related operations
95105
$connection->beginTransaction();
106+
$userType = $this->userContext->getUserType();
107+
if ($userType === null) {
108+
$userType = UserContextInterface::USER_TYPE_ADMIN;
109+
}
96110
try {
97111
/** @var \Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface $bulkSummary */
98112
$bulkSummary = $this->bulkSummaryFactory->create();
99113
$this->entityManager->load($bulkSummary, $bulkUuid);
100114
$bulkSummary->setBulkId($bulkUuid);
101115
$bulkSummary->setDescription($description);
102116
$bulkSummary->setUserId($userId);
117+
$bulkSummary->setUserType($userType);
103118
$bulkSummary->setOperationCount((int)$bulkSummary->getOperationCount() + count($operations));
104119

105120
$this->entityManager->save($bulkSummary);

app/code/Magento/AsynchronousOperations/Model/BulkSummary.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ public function setUserId($userId)
7878
return $this->setData(self::USER_ID, $userId);
7979
}
8080

81+
/**
82+
* @inheritDoc
83+
*/
84+
public function getUserType()
85+
{
86+
return $this->getData(self::USER_TYPE);
87+
}
88+
89+
/**
90+
* @inheritDoc
91+
*/
92+
public function setUserType($userType)
93+
{
94+
return $this->setData(self::USER_TYPE, $userType);
95+
}
96+
8197
/**
8298
* @inheritDoc
8399
*/

app/code/Magento/AsynchronousOperations/Model/MassSchedule.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Magento\AsynchronousOperations\Model;
1010

11+
use Magento\Framework\App\ObjectManager;
1112
use Magento\Framework\DataObject\IdentityGeneratorInterface;
1213
use Magento\Framework\Exception\LocalizedException;
1314
use Magento\AsynchronousOperations\Api\Data\ItemStatusInterfaceFactory;
@@ -18,9 +19,12 @@
1819
use Magento\Framework\Exception\BulkException;
1920
use Psr\Log\LoggerInterface;
2021
use Magento\AsynchronousOperations\Model\ResourceModel\Operation\OperationRepository;
22+
use Magento\Authorization\Model\UserContextInterface;
2123

2224
/**
2325
* Class MassSchedule used for adding multiple entities as Operations to Bulk Management with the status tracking
26+
*
27+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) Suppressed without refactoring to not introduce BiC
2428
*/
2529
class MassSchedule
2630
{
@@ -54,6 +58,11 @@ class MassSchedule
5458
*/
5559
private $operationRepository;
5660

61+
/**
62+
* @var \Magento\Authorization\Model\UserContextInterface
63+
*/
64+
private $userContext;
65+
5766
/**
5867
* Initialize dependencies.
5968
*
@@ -63,30 +72,33 @@ class MassSchedule
6372
* @param BulkManagementInterface $bulkManagement
6473
* @param LoggerInterface $logger
6574
* @param OperationRepository $operationRepository
75+
* @param UserContextInterface $userContext
6676
*/
6777
public function __construct(
6878
IdentityGeneratorInterface $identityService,
6979
ItemStatusInterfaceFactory $itemStatusInterfaceFactory,
7080
AsyncResponseInterfaceFactory $asyncResponseFactory,
7181
BulkManagementInterface $bulkManagement,
7282
LoggerInterface $logger,
73-
OperationRepository $operationRepository
83+
OperationRepository $operationRepository,
84+
UserContextInterface $userContext = null
7485
) {
7586
$this->identityService = $identityService;
7687
$this->itemStatusInterfaceFactory = $itemStatusInterfaceFactory;
7788
$this->asyncResponseFactory = $asyncResponseFactory;
7889
$this->bulkManagement = $bulkManagement;
7990
$this->logger = $logger;
8091
$this->operationRepository = $operationRepository;
92+
$this->userContext = $userContext ?: ObjectManager::getInstance()->get(UserContextInterface::class);
8193
}
8294

8395
/**
8496
* Schedule new bulk operation based on the list of entities
8597
*
86-
* @param $topicName
87-
* @param $entitiesArray
88-
* @param null $groupId
89-
* @param null $userId
98+
* @param string $topicName
99+
* @param array $entitiesArray
100+
* @param string $groupId
101+
* @param string $userId
90102
* @return AsyncResponseInterface
91103
* @throws BulkException
92104
* @throws LocalizedException
@@ -95,6 +107,10 @@ public function publishMass($topicName, array $entitiesArray, $groupId = null, $
95107
{
96108
$bulkDescription = __('Topic %1', $topicName);
97109

110+
if ($userId == null) {
111+
$userId = $this->userContext->getUserId();
112+
}
113+
98114
if ($groupId == null) {
99115
$groupId = $this->identityService->generateId();
100116

app/code/Magento/AsynchronousOperations/Test/Unit/Model/BulkManagementTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public function testScheduleBulk()
108108
$bulkUuid = 'bulk-001';
109109
$description = 'Bulk summary description...';
110110
$userId = 1;
111+
$userType = \Magento\Authorization\Model\UserContextInterface::USER_TYPE_ADMIN;
111112
$connectionName = 'default';
112113
$topicNames = ['topic.name.0', 'topic.name.1'];
113114
$operation = $this->getMockBuilder(\Magento\AsynchronousOperations\Api\Data\OperationInterface::class)
@@ -131,6 +132,7 @@ public function testScheduleBulk()
131132
$bulkSummary->expects($this->once())->method('setBulkId')->with($bulkUuid)->willReturnSelf();
132133
$bulkSummary->expects($this->once())->method('setDescription')->with($description)->willReturnSelf();
133134
$bulkSummary->expects($this->once())->method('setUserId')->with($userId)->willReturnSelf();
135+
$bulkSummary->expects($this->once())->method('setUserType')->with($userType)->willReturnSelf();
134136
$bulkSummary->expects($this->once())->method('getOperationCount')->willReturn(1);
135137
$bulkSummary->expects($this->once())->method('setOperationCount')->with(3)->willReturnSelf();
136138
$this->entityManager->expects($this->once())->method('save')->with($bulkSummary)->willReturn($bulkSummary);

app/code/Magento/AsynchronousOperations/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"magento/module-authorization": "*",
1111
"magento/module-backend": "*",
1212
"magento/module-ui": "*",
13-
"magento/module-user": "*",
1413
"php": "~7.1.3||~7.2.0"
1514
},
1615
"suggest": {

app/code/Magento/AsynchronousOperations/etc/db_schema.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
<column xsi:type="varbinary" name="uuid" nullable="true" length="39"
1515
comment="Bulk UUID (can be exposed to reference bulk entity)"/>
1616
<column xsi:type="int" name="user_id" padding="10" unsigned="true" nullable="true" identity="false"
17-
comment="ID of the user that performed an action"/>
17+
comment="ID of the WebAPI user that performed an action"/>
18+
<column xsi:type="int" name="user_type" nullable="true" comment="Which type of user"/>
1819
<column xsi:type="varchar" name="description" nullable="true" length="255" comment="Bulk Description"/>
1920
<column xsi:type="int" name="operation_count" padding="10" unsigned="true" nullable="false" identity="false"
2021
comment="Total number of operations scheduled within this bulk"/>
@@ -23,11 +24,12 @@
2324
<constraint xsi:type="primary" name="PRIMARY">
2425
<column name="id"/>
2526
</constraint>
26-
<constraint xsi:type="foreign" name="MAGENTO_BULK_USER_ID_ADMIN_USER_USER_ID" table="magento_bulk"
27-
column="user_id" referenceTable="admin_user" referenceColumn="user_id" onDelete="CASCADE"/>
2827
<constraint xsi:type="unique" name="MAGENTO_BULK_UUID">
2928
<column name="uuid"/>
3029
</constraint>
30+
<index name="MAGENTO_BULK_USER_ID_ADMIN_USER_USER_ID" indexType="btree">
31+
<column name="user_id"/>
32+
</index>
3133
</table>
3234
<table name="magento_operation" resource="default" engine="innodb" comment="Operation entity">
3335
<column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true"

app/code/Magento/AsynchronousOperations/etc/db_schema_whitelist.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
"id": true,
55
"uuid": true,
66
"user_id": true,
7+
"user_type": true,
78
"description": true,
89
"operation_count": true,
910
"start_time": true
1011
},
12+
"index": {
13+
"MAGENTO_BULK_USER_ID_ADMIN_USER_USER_ID": true,
14+
"MAGENTO_BULK_USER_ID": true
15+
},
1116
"constraint": {
1217
"PRIMARY": true,
13-
"MAGENTO_BULK_USER_ID_ADMIN_USER_USER_ID": true,
1418
"MAGENTO_BULK_UUID": true
1519
}
1620
},

0 commit comments

Comments
 (0)