Skip to content

Commit 83dab7e

Browse files
Merge branch '2.4-develop' into ref-AdminCreateInvoiceTest
2 parents ce7a351 + 05a3e7e commit 83dab7e

File tree

818 files changed

+24434
-5518
lines changed

Some content is hidden

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

818 files changed

+24434
-5518
lines changed

app/code/Magento/AdminAnalytics/Test/Mftf/Test/AdminCheckAnalyticsTrackingTest.xml

+41
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,46 @@
3131

3232
<waitForPageLoad stepKey="waitForPageReloaded"/>
3333
<seeInPageSource html="var adminAnalyticsMetadata =" stepKey="seeInPageSource"/>
34+
<grabPageSource stepKey="pageSource"/>
35+
<assertRegExp message="adminAnalyticsMetadata object is invalid" stepKey="validateadminAnalyticsMetadata">
36+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?("[\w_]+":\s+"[^"]*?"\s+)};#s</expectedResult>
37+
<actualResult type="variable">$pageSource</actualResult>
38+
</assertRegExp>
39+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect user ID" stepKey="validateUserId">
40+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"user":\s+"[\w\d]{64}"#s</expectedResult>
41+
<actualResult type="variable">$pageSource</actualResult>
42+
</assertRegExp>
43+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect secure base URL" stepKey="validateSecureBaseURL">
44+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"secure_base_url":\s+"http(s)?\\\\u003A\\\\u002F\\\\u002F.+?\\\\u002F"#s</expectedResult>
45+
<actualResult type="variable">$pageSource</actualResult>
46+
</assertRegExp>
47+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect product version" stepKey="validateProductVersion">
48+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"version":\s+"[^\s]+"#s</expectedResult>
49+
<actualResult type="variable">$pageSource</actualResult>
50+
</assertRegExp>
51+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect product edition" stepKey="validateProductEdition">
52+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"product_edition":\s+"(Community|Enterprise|B2B)"#s</expectedResult>
53+
<actualResult type="variable">$pageSource</actualResult>
54+
</assertRegExp>
55+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect application mode" stepKey="validateApplicationMode">
56+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"mode":\s+"default|developer|production"#s</expectedResult>
57+
<actualResult type="variable">$pageSource</actualResult>
58+
</assertRegExp>
59+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect store name" stepKey="validateStoreName">
60+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"store_name_default":\s+".*?"#s</expectedResult>
61+
<actualResult type="variable">$pageSource</actualResult>
62+
</assertRegExp>
63+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect admin user created date" stepKey="validateAdminUserCreatedDate">
64+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"admin_user_created":\s+".+?"#s</expectedResult>
65+
<actualResult type="variable">$pageSource</actualResult>
66+
</assertRegExp>
67+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect admin user log date" stepKey="validateAdminUserLogDate">
68+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"admin_user_logdate":\s+".+?"#s</expectedResult>
69+
<actualResult type="variable">$pageSource</actualResult>
70+
</assertRegExp>
71+
<assertRegExp message="adminAnalyticsMetadata object contains incorrect admin user role name" stepKey="validateAdminUserRoleName">
72+
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"admin_user_role_name":\s+".+?"#s</expectedResult>
73+
<actualResult type="variable">$pageSource</actualResult>
74+
</assertRegExp>
3475
</test>
3576
</tests>

app/code/Magento/AdminAnalytics/ViewModel/Metadata.php

+85-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
8+
69
namespace Magento\AdminAnalytics\ViewModel;
710

11+
use Magento\Config\Model\Config\Backend\Admin\Custom;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
813
use Magento\Framework\App\ProductMetadataInterface;
914
use Magento\Backend\Model\Auth\Session;
1015
use Magento\Framework\App\State;
1116
use Magento\Framework\View\Element\Block\ArgumentInterface;
17+
use Magento\Store\Model\Information;
1218

1319
/**
1420
* Gets user version and mode
@@ -30,19 +36,27 @@ class Metadata implements ArgumentInterface
3036
*/
3137
private $productMetadata;
3238

39+
/**
40+
* @var ScopeConfigInterface
41+
*/
42+
private $config;
43+
3344
/**
3445
* @param ProductMetadataInterface $productMetadata
3546
* @param Session $authSession
3647
* @param State $appState
48+
* @param ScopeConfigInterface $config
3749
*/
3850
public function __construct(
3951
ProductMetadataInterface $productMetadata,
4052
Session $authSession,
41-
State $appState
53+
State $appState,
54+
ScopeConfigInterface $config
4255
) {
4356
$this->productMetadata = $productMetadata;
4457
$this->authSession = $authSession;
4558
$this->appState = $appState;
59+
$this->config = $config;
4660
}
4761

4862
/**
@@ -55,15 +69,26 @@ public function getMagentoVersion() :string
5569
return $this->productMetadata->getVersion();
5670
}
5771

72+
/**
73+
* Get product edition
74+
*
75+
* @return string
76+
*/
77+
public function getProductEdition(): string
78+
{
79+
return $this->productMetadata->getEdition();
80+
}
81+
5882
/**
5983
* Get current user id (hash generated from email)
6084
*
6185
* @return string
6286
*/
6387
public function getCurrentUser() :string
6488
{
65-
return hash('sha512', 'ADMIN_USER' . $this->authSession->getUser()->getEmail());
89+
return hash('sha256', 'ADMIN_USER' . $this->authSession->getUser()->getEmail());
6690
}
91+
6792
/**
6893
* Get Magento mode that the user is using
6994
*
@@ -73,4 +98,62 @@ public function getMode() :string
7398
{
7499
return $this->appState->getMode();
75100
}
101+
102+
/**
103+
* Get created date for current user
104+
*
105+
* @return string
106+
*/
107+
public function getCurrentUserCreatedDate(): string
108+
{
109+
return $this->authSession->getUser()->getCreated();
110+
}
111+
112+
/**
113+
* Get log date for current user
114+
*
115+
* @return string|null
116+
*/
117+
public function getCurrentUserLogDate(): ?string
118+
{
119+
return $this->authSession->getUser()->getLogdate();
120+
}
121+
122+
/**
123+
* Get secure base URL
124+
*
125+
* @param string $scope
126+
* @param string|null $scopeCode
127+
* @return string|null
128+
*/
129+
public function getSecureBaseUrlForScope(
130+
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
131+
?string $scopeCode = null
132+
): ?string {
133+
return $this->config->getValue(Custom::XML_PATH_SECURE_BASE_URL, $scope, $scopeCode);
134+
}
135+
136+
/**
137+
* Get store name
138+
*
139+
* @param string $scope
140+
* @param string|null $scopeCode
141+
* @return string|null
142+
*/
143+
public function getStoreNameForScope(
144+
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
145+
?string $scopeCode = null
146+
): ?string {
147+
return $this->config->getValue(Information::XML_PATH_STORE_INFO_NAME, $scope, $scopeCode);
148+
}
149+
150+
/**
151+
* Get current user role name
152+
*
153+
* @return string
154+
*/
155+
public function getCurrentUserRoleName(): string
156+
{
157+
return $this->authSession->getUser()->getRole()->getRoleName();
158+
}
76159
}

app/code/Magento/AdminAnalytics/composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"magento/framework": "*",
1010
"magento/module-backend": "*",
1111
"magento/module-config": "*",
12+
"magento/module-store": "*",
1213
"magento/module-ui": "*",
1314
"magento/module-release-notification": "*"
1415
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
10+
<policies>
11+
<policy id="script-src">
12+
<values>
13+
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
14+
</values>
15+
</policy>
16+
<policy id="style-src">
17+
<values>
18+
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
19+
<value id="fonts_googleapis" type="host">fonts.googleapis.com</value>
20+
</values>
21+
</policy>
22+
<policy id="img-src">
23+
<values>
24+
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
25+
<value id="storage_googleapis" type="host">storage.googleapis.com</value>
26+
</values>
27+
</policy>
28+
<policy id="connect-src">
29+
<values>
30+
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
31+
</values>
32+
</policy>
33+
<policy id="font-src">
34+
<values>
35+
<value id="fonts_gstatic" type="host">fonts.gstatic.com</value>
36+
</values>
37+
</policy>
38+
</policies>
39+
</csp_whitelist>

app/code/Magento/AdminAnalytics/view/adminhtml/layout/default.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<referenceContainer name="header">
1111
<block name="tracking" as="tracking" template="Magento_AdminAnalytics::tracking.phtml" ifconfig="admin/usage/enabled">
1212
<arguments>
13-
<argument name="tracking_url" xsi:type="string">//assets.adobedtm.com/launch-EN30eb7ffa064444f1b8b0368ef38fd3a9.min.js</argument>
13+
<argument name="tracking_url" xsi:type="string">//assets.adobedtm.com/a7d65461e54e/37baabec1b6e/launch-177bc126c8e6.min.js</argument>
1414
<argument name="metadata" xsi:type="object">Magento\AdminAnalytics\ViewModel\Metadata</argument>
1515
</arguments>
1616
</block>

app/code/Magento/AdminAnalytics/view/adminhtml/templates/tracking.phtml

+13-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,20 @@
1919
false
2020
) ?>
2121

22-
<?php $scriptString = '
22+
<?php
23+
/** @var \Magento\AdminAnalytics\ViewModel\Metadata $metadata */
24+
$metadata = $block->getMetadata();
25+
$scriptString = '
2326
var adminAnalyticsMetadata = {
24-
"version": "' . $block->escapeJs($block->getMetadata()->getMagentoVersion()) . '",
25-
"user": "' . $block->escapeJs($block->getMetadata()->getCurrentUser()) . '",
26-
"mode": "' . $block->escapeJs($block->getMetadata()->getMode()) . '"
27+
"secure_base_url": "' . $block->escapeJs($metadata->getSecureBaseUrlForScope()) . '",
28+
"version": "' . $block->escapeJs($metadata->getMagentoVersion()) . '",
29+
"product_edition": "' . $block->escapeJs($metadata->getProductEdition()) . '",
30+
"user": "' . $block->escapeJs($metadata->getCurrentUser()) . '",
31+
"mode": "' . $block->escapeJs($metadata->getMode()) . '",
32+
"store_name_default": "' . $block->escapeJs($metadata->getStoreNameForScope()) . '",
33+
"admin_user_created": "' . $block->escapeJs($metadata->getCurrentUserCreatedDate()) . '",
34+
"admin_user_logdate": "' . $block->escapeJs($metadata->getCurrentUserLogDate()) . '",
35+
"admin_user_role_name": "' . $block->escapeJs($metadata->getCurrentUserRoleName()) . '"
2736
};
2837
';
2938
?>

app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,8 @@ private function fetchTierPrices(array $productIds): array
486486
)
487487
->where(
488488
'ap.' . $productEntityLinkField . ' IN (?)',
489-
$productIds
489+
$productIds,
490+
\Zend_Db::INT_TYPE
490491
);
491492

492493
if ($priceFromFilter !== null) {

app/code/Magento/Analytics/etc/config.xml

+7
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,12 @@
2323
<token/>
2424
</general>
2525
</analytics>
26+
<system>
27+
<media_storage_configuration>
28+
<allowed_resources>
29+
<analytics_folder>analytics</analytics_folder>
30+
</allowed_resources>
31+
</media_storage_configuration>
32+
</system>
2633
</default>
2734
</config>

app/code/Magento/Authorization/Model/Rules.php

+9-23
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,30 @@
2525
class Rules extends \Magento\Framework\Model\AbstractModel
2626
{
2727
/**
28-
* Class constructor
29-
*
30-
* @param \Magento\Framework\Model\Context $context
31-
* @param \Magento\Framework\Registry $registry
32-
* @param \Magento\Authorization\Model\ResourceModel\Rules $resource
33-
* @param \Magento\Authorization\Model\ResourceModel\Rules\Collection $resourceCollection
34-
* @param array $data
35-
*/
36-
public function __construct(
37-
\Magento\Framework\Model\Context $context,
38-
\Magento\Framework\Registry $registry,
39-
\Magento\Authorization\Model\ResourceModel\Rules $resource,
40-
\Magento\Authorization\Model\ResourceModel\Rules\Collection $resourceCollection,
41-
array $data = []
42-
) {
43-
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
44-
}
45-
46-
/**
47-
* Class constructor
48-
*
49-
* @return void
28+
* @inheritdoc
5029
*/
5130
protected function _construct()
5231
{
5332
$this->_init(\Magento\Authorization\Model\ResourceModel\Rules::class);
5433
}
5534

5635
/**
36+
* Obsolete method of update
37+
*
5738
* @return $this
39+
* @deprecated Method was never implemented and used.
5840
*/
5941
public function update()
6042
{
61-
$this->getResource()->update($this);
43+
// phpcs:disable Magento2.Functions.DiscouragedFunction
44+
trigger_error('Method was never implemented and used.', E_USER_DEPRECATED);
45+
6246
return $this;
6347
}
6448

6549
/**
50+
* Save authorization rule relation
51+
*
6652
* @return $this
6753
*/
6854
public function saveRel()

app/code/Magento/AwsS3/Driver/AwsS3.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ public function getAbsolutePath($basePath, $path, $scheme = null)
304304
* Resolves relative path.
305305
*
306306
* @param string $path Absolute path
307+
* @param bool $fixPath
307308
* @return string Relative path
308309
*/
309310
private function normalizeRelativePath(string $path, bool $fixPath = false): string
@@ -358,7 +359,7 @@ public function isFile($path): bool
358359
return false;
359360
}
360361

361-
$path = $this->normalizeRelativePath($path, true);;
362+
$path = $this->normalizeRelativePath($path, true);
362363

363364
if ($this->adapter->has($path) && ($meta = $this->adapter->getMetadata($path))) {
364365
return ($meta['type'] ?? null) === self::TYPE_FILE;

app/code/Magento/AwsS3/Driver/AwsS3Factory.php

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public function createConfigured(
8686
throw new DriverException(__('Bucket and region are required values'));
8787
}
8888

89+
if (!empty($config['http_handler'])) {
90+
$config['http_handler'] = $this->objectManager->create($config['http_handler'])($config);
91+
}
92+
8993
$client = new S3Client($config);
9094
$adapter = new AwsS3Adapter($client, $config['bucket'], $prefix);
9195

0 commit comments

Comments
 (0)