Skip to content

Commit 5e06d65

Browse files
Merge branch '2.4-develop' into GL_PR_Arrows_August_07_2023
2 parents c3f2eb9 + 3d11501 commit 5e06d65

File tree

26 files changed

+432
-92
lines changed

26 files changed

+432
-92
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\BundleGraphQl\Model\Resolver;
9+
10+
use Magento\Catalog\Model\Product;
11+
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\GraphQl\Config\Element\Field;
13+
use Magento\Framework\GraphQl\Query\ResolverInterface;
14+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
15+
16+
class BundlePriceDetails implements ResolverInterface
17+
{
18+
/**
19+
* @inheritdoc
20+
*/
21+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
22+
{
23+
if (!isset($value['model'])) {
24+
throw new LocalizedException(__('"model" value should be specified'));
25+
}
26+
/** @var Product $product */
27+
$product = $value['model'];
28+
29+
$price = $product->getPrice();
30+
$finalPrice = $product->getFinalPrice();
31+
$discountPercentage = 100 - (($finalPrice * 100) / $price);
32+
return [
33+
'main_price' => $price,
34+
'main_final_price' => $finalPrice,
35+
'discount_percentage' => $discountPercentage
36+
];
37+
}
38+
}

app/code/Magento/BundleGraphQl/etc/schema.graphqls

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ type SelectedBundleOptionValue @doc(description: "Contains details about a value
4747
price: Float! @doc(description: "The price of the value for the selected bundle product option.")
4848
}
4949

50+
type PriceDetails @doc(description: "Can be used to retrieve the main price details in case of bundle product") {
51+
main_price: Float @doc(description: "The regular price of the main product")
52+
main_final_price: Float @doc(description: "The final price after applying the discount to the main product")
53+
discount_percentage: Float @doc(description: "The percentage of discount applied to the main product price")
54+
}
55+
5056
type BundleItem @doc(description: "Defines an individual item within a bundle product.") {
5157
option_id: Int @deprecated(reason: "Use `uid` instead") @doc(description: "An ID assigned to each type of item in a bundle product.")
5258
uid: ID @doc(description: "The unique ID for a `BundleItem` object.")
@@ -79,6 +85,7 @@ type BundleProduct implements ProductInterface, RoutableInterface, PhysicalProdu
7985
dynamic_sku: Boolean @doc(description: "Indicates whether the bundle product has a dynamic SKU.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Product\\Fields\\DynamicSku")
8086
ship_bundle_items: ShipBundleItemsEnum @doc(description: "Indicates whether to ship bundle items together or individually.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Product\\Fields\\ShipBundleItems")
8187
dynamic_weight: Boolean @doc(description: "Indicates whether the bundle product has a dynamically calculated weight.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\Product\\Fields\\DynamicWeight")
88+
price_details: PriceDetails @doc(description: "The price details of the main product") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\BundlePriceDetails")
8289
items: [BundleItem] @doc(description: "An array containing information about individual bundle items.") @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\BundleItems")
8390
}
8491

app/code/Magento/Customer/Model/Address/AbstractAddress.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ public function getRegionId()
453453
(string)$this->getRegionCode(),
454454
(string)$this->getCountryId()
455455
);
456+
if (empty($regionId)) {
457+
$regionId = $this->getData('region_id');
458+
}
456459
$this->setData('region_id', $regionId);
457460
}
458461

app/code/Magento/Customer/Plugin/Webapi/Controller/Rest/ValidateCustomerData.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class ValidateCustomerData
2828
*/
2929
public function beforeOverride(ParamsOverrider $subject, array $inputData, array $parameters): array
3030
{
31-
if (isset($inputData[self:: CUSTOMER_KEY])) {
32-
$inputData[self:: CUSTOMER_KEY] = $this->validateInputData($inputData[self:: CUSTOMER_KEY]);
31+
if (isset($inputData[self::CUSTOMER_KEY])) {
32+
$inputData[self::CUSTOMER_KEY] = $this->validateInputData($inputData[self::CUSTOMER_KEY]);
3333
}
3434
return [$inputData, $parameters];
3535
}
@@ -45,7 +45,7 @@ private function validateInputData(array $inputData): array
4545
$result = [];
4646

4747
$data = array_filter($inputData, function ($k) use (&$result) {
48-
$key = is_string($k) ? strtolower($k) : $k;
48+
$key = is_string($k) ? strtolower(str_replace('_', "", $k)) : $k;
4949
return !isset($result[$key]) && ($result[$key] = true);
5050
}, ARRAY_FILTER_USE_KEY);
5151

app/code/Magento/Customer/Test/Mftf/Test/StorefrontLoginFormShowPasswordTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</actionGroup>
3232
<actionGroup ref="StorefrontLoginFormClickShowPasswordActionGroup" stepKey="clickShowPasswordCheckbox"/>
3333
<actionGroup ref="AssertLoginFormPasswordFieldActionGroup" stepKey="AssertPasswordField">
34-
<argument name="passwordFieldType" value="password"/>
34+
<argument name="passwordFieldType" value="text"/>
3535
</actionGroup>
3636
</test>
3737
</tests>

app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,29 @@ public function testGetRegionCodeWithRegionId()
162162
$this->assertEquals('UK', $this->model->getRegionCode());
163163
}
164164

165+
/**
166+
* Test regionid for empty value
167+
*
168+
* @inheritdoc
169+
* @return void
170+
*/
171+
public function testGetRegionId()
172+
{
173+
$this->model->setData('region_id', 0);
174+
$this->model->setData('region', '');
175+
$this->model->setData('country_id', 'GB');
176+
$region = $this->getMockBuilder(Region::class)
177+
->addMethods(['getCountryId', 'getCode'])
178+
->onlyMethods(['__wakeup', 'load', 'loadByCode','getId'])
179+
->disableOriginalConstructor()
180+
->getMock();
181+
$region->method('loadByCode')
182+
->willReturnSelf();
183+
$this->regionFactoryMock->method('create')
184+
->willReturn($region);
185+
$this->assertEquals(0, $this->model->getRegionId());
186+
}
187+
165188
public function testGetRegionCodeWithRegion()
166189
{
167190
$countryId = 2;

app/code/Magento/Customer/Test/Unit/Plugin/Webapi/Controller/Rest/ValidateCustomerDataTest.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
namespace Magento\Customer\Test\Unit\Plugin\Webapi\Controller\Rest;
99

1010
use Exception;
11-
use Magento\Framework\App\ObjectManager;
1211
use Magento\Customer\Plugin\Webapi\Controller\Rest\ValidateCustomerData;
12+
use Magento\Framework\App\ObjectManager;
1313
use PHPUnit\Framework\TestCase;
1414
use ReflectionClass;
1515

@@ -75,40 +75,48 @@ public function dataProviderInputData(): array
7575
{
7676
return [
7777
[
78-
['customer' =>
79-
[
78+
['customer' => [
8079
'id' => -1,
8180
'Id' => 1,
82-
'name' =>
83-
[
81+
'name' => [
8482
'firstName' => 'Test',
8583
'LastName' => 'user'
8684
],
8785
'isHavingOwnHouse' => 1,
88-
'address' =>
89-
[
86+
'address' => [
9087
'street' => '1st Street',
9188
'Street' => '3rd Street',
9289
'city' => 'London'
9390
],
9491
]
9592
],
96-
['customer' =>
97-
[
93+
['customer' => [
9894
'id' => -1,
99-
'name' =>
100-
[
95+
'name' => [
10196
'firstName' => 'Test',
10297
'LastName' => 'user'
10398
],
10499
'isHavingOwnHouse' => 1,
105-
'address' =>
106-
[
100+
'address' => [
107101
'street' => '1st Street',
108102
'city' => 'London'
109103
],
110104
]
111105
],
106+
['customer' => [
107+
'id' => -1,
108+
'_Id' => 1,
109+
'name' => [
110+
'firstName' => 'Test',
111+
'LastName' => 'user'
112+
],
113+
'isHavingOwnHouse' => 1,
114+
'address' => [
115+
'street' => '1st Street',
116+
'city' => 'London'
117+
],
118+
]
119+
],
112120
]
113121
];
114122
}

app/code/Magento/Customer/view/frontend/templates/form/login.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<div class="control">
3838
<input name="login[password]" type="password"
3939
<?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?>
40-
class="input-text" id="pass"
40+
class="input-text" id="password"
4141
title="<?= $block->escapeHtmlAttr(__('Password')) ?>"
4242
data-validate="{required:true}">
4343
</div>
@@ -68,7 +68,7 @@
6868
"components": {
6969
"showPassword": {
7070
"component": "Magento_Customer/js/show-password",
71-
"passwordSelector": "#pass"
71+
"passwordSelector": "#password"
7272
}
7373
}
7474
}

app/code/Magento/Customer/view/frontend/web/js/show-password.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* Copyright © Magento, Inc. All rights reserved.
3-
* See COPYING.txt for license details.
4-
*/
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
55

66
define([
77
'jquery',

app/code/Magento/EncryptionKey/Model/ResourceModel/Key/Change.php

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,22 @@
55
*/
66
namespace Magento\EncryptionKey\Model\ResourceModel\Key;
77

8+
use \Exception;
9+
use Magento\Config\Model\Config\Backend\Encrypted;
10+
use Magento\Config\Model\Config\Structure;
11+
use Magento\Framework\App\DeploymentConfig\Writer;
812
use Magento\Framework\App\Filesystem\DirectoryList;
913
use Magento\Framework\Config\ConfigOptionsListConstants;
1014
use Magento\Framework\Config\Data\ConfigData;
1115
use Magento\Framework\Config\File\ConfigFilePool;
16+
use Magento\Framework\Encryption\EncryptorInterface;
17+
use Magento\Framework\Exception\FileSystemException;
18+
use Magento\Framework\Exception\LocalizedException;
19+
use Magento\Framework\Filesystem;
20+
use Magento\Framework\Filesystem\Directory\WriteInterface;
21+
use Magento\Framework\Math\Random;
22+
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
23+
use Magento\Framework\Model\ResourceModel\Db\Context;
1224

1325
/**
1426
* Encryption key changer resource model
@@ -19,60 +31,60 @@
1931
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2032
* @since 100.0.2
2133
*/
22-
class Change extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
34+
class Change extends AbstractDb
2335
{
2436
/**
2537
* Encryptor interface
2638
*
27-
* @var \Magento\Framework\Encryption\EncryptorInterface
39+
* @var EncryptorInterface
2840
*/
2941
protected $encryptor;
3042

3143
/**
3244
* Filesystem directory write interface
3345
*
34-
* @var \Magento\Framework\Filesystem\Directory\WriteInterface
46+
* @var WriteInterface
3547
*/
3648
protected $directory;
3749

3850
/**
3951
* System configuration structure
4052
*
41-
* @var \Magento\Config\Model\Config\Structure
53+
* @var Structure
4254
*/
4355
protected $structure;
4456

4557
/**
4658
* Configuration writer
4759
*
48-
* @var \Magento\Framework\App\DeploymentConfig\Writer
60+
* @var Writer
4961
*/
5062
protected $writer;
5163

5264
/**
53-
* Random
65+
* Random string generator
5466
*
55-
* @var \Magento\Framework\Math\Random
67+
* @var Random
5668
* @since 100.0.4
5769
*/
5870
protected $random;
5971

6072
/**
61-
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
62-
* @param \Magento\Framework\Filesystem $filesystem
63-
* @param \Magento\Config\Model\Config\Structure $structure
64-
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
65-
* @param \Magento\Framework\App\DeploymentConfig\Writer $writer
66-
* @param \Magento\Framework\Math\Random $random
73+
* @param Context $context
74+
* @param Filesystem $filesystem
75+
* @param Structure $structure
76+
* @param EncryptorInterface $encryptor
77+
* @param Writer $writer
78+
* @param Random $random
6779
* @param string $connectionName
6880
*/
6981
public function __construct(
70-
\Magento\Framework\Model\ResourceModel\Db\Context $context,
71-
\Magento\Framework\Filesystem $filesystem,
72-
\Magento\Config\Model\Config\Structure $structure,
73-
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
74-
\Magento\Framework\App\DeploymentConfig\Writer $writer,
75-
\Magento\Framework\Math\Random $random,
82+
Context $context,
83+
Filesystem $filesystem,
84+
Structure $structure,
85+
EncryptorInterface $encryptor,
86+
Writer $writer,
87+
Random $random,
7688
$connectionName = null
7789
) {
7890
$this->encryptor = clone $encryptor;
@@ -98,20 +110,18 @@ protected function _construct()
98110
*
99111
* @param string|null $key
100112
* @return null|string
101-
* @throws \Exception
113+
* @throws FileSystemException|LocalizedException|Exception
102114
*/
103115
public function changeEncryptionKey($key = null)
104116
{
105117
// prepare new key, encryptor and new configuration segment
106118
if (!$this->writer->checkIfWritable()) {
107-
throw new \Exception(__('Deployment configuration file is not writable.'));
119+
throw new FileSystemException(__('Deployment configuration file is not writable.'));
108120
}
109121

110122
if (null === $key) {
111-
// md5() here is not for cryptographic use. It used for generate encryption key itself
112-
// and do not encrypt any passwords
113-
// phpcs:ignore Magento2.Security.InsecureFunction
114-
$key = md5($this->random->getRandomString(ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE));
123+
$key = ConfigOptionsListConstants::STORE_KEY_ENCODED_RANDOM_STRING_PREFIX .
124+
$this->random->getRandomBytes(ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE);
115125
}
116126
$this->encryptor->setNewKey($key);
117127

@@ -128,7 +138,7 @@ public function changeEncryptionKey($key = null)
128138
$this->writer->saveConfig($configData);
129139
$this->commit();
130140
return $key;
131-
} catch (\Exception $e) {
141+
} catch (LocalizedException $e) {
132142
$this->rollBack();
133143
throw $e;
134144
}
@@ -142,11 +152,11 @@ public function changeEncryptionKey($key = null)
142152
protected function _reEncryptSystemConfigurationValues()
143153
{
144154
// look for encrypted node entries in all system.xml files
145-
/** @var \Magento\Config\Model\Config\Structure $configStructure */
155+
/** @var Structure $configStructure */
146156
$configStructure = $this->structure;
147157
$paths = $configStructure->getFieldPathsByAttribute(
148158
'backend_model',
149-
\Magento\Config\Model\Config\Backend\Encrypted::class
159+
Encrypted::class
150160
);
151161

152162
// walk through found data and re-encrypt it

0 commit comments

Comments
 (0)