Skip to content

Commit 6b6a12b

Browse files
committed
Merge remote-tracking branch 'origin/MC-19194' into hb-combined-pr
2 parents 33456b1 + fbaecf0 commit 6b6a12b

File tree

17 files changed

+36
-388
lines changed

17 files changed

+36
-388
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ public function execute(Quote $cart, int $cartItemId, float $quantity, array $cu
9393
)
9494
);
9595
}
96-
97-
$this->quoteRepository->save($cart);
9896
}
9997

10098
/**
@@ -105,7 +103,7 @@ public function execute(Quote $cart, int $cartItemId, float $quantity, array $cu
105103
* @param float $quantity
106104
* @throws GraphQlNoSuchEntityException
107105
* @throws NoSuchEntityException
108-
* @throws GraphQlNoSuchEntityException
106+
* @throws GraphQlInputException
109107
*/
110108
private function updateItemQuantity(int $itemId, Quote $cart, float $quantity)
111109
{
@@ -117,7 +115,6 @@ private function updateItemQuantity(int $itemId, Quote $cart, float $quantity)
117115
}
118116
$cartItem->setQty($quantity);
119117
$this->validateCartItem($cartItem);
120-
$this->cartItemRepository->save($cartItem);
121118
}
122119

123120
/**

app/code/Magento/QuoteGraphQl/Model/Resolver/UpdateCartItems.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Framework\GraphQl\Query\ResolverInterface;
1616
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1717
use Magento\Quote\Api\CartItemRepositoryInterface;
18+
use Magento\Quote\Api\CartRepositoryInterface;
1819
use Magento\Quote\Model\Quote;
1920
use Magento\QuoteGraphQl\Model\Cart\GetCartForUser;
2021
use Magento\QuoteGraphQl\Model\Cart\UpdateCartItem;
@@ -39,19 +40,27 @@ class UpdateCartItems implements ResolverInterface
3940
*/
4041
private $cartItemRepository;
4142

43+
/**
44+
* @var CartRepositoryInterface
45+
*/
46+
private $cartRepository;
47+
4248
/**
4349
* @param GetCartForUser $getCartForUser
4450
* @param CartItemRepositoryInterface $cartItemRepository
4551
* @param UpdateCartItem $updateCartItem
52+
* @param CartRepositoryInterface $cartRepository
4653
*/
4754
public function __construct(
4855
GetCartForUser $getCartForUser,
4956
CartItemRepositoryInterface $cartItemRepository,
50-
UpdateCartItem $updateCartItem
57+
UpdateCartItem $updateCartItem,
58+
CartRepositoryInterface $cartRepository
5159
) {
5260
$this->getCartForUser = $getCartForUser;
5361
$this->cartItemRepository = $cartItemRepository;
5462
$this->updateCartItem = $updateCartItem;
63+
$this->cartRepository = $cartRepository;
5564
}
5665

5766
/**
@@ -76,6 +85,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
7685

7786
try {
7887
$this->processCartItems($cart, $cartItems);
88+
$this->cartRepository->save($cart);
7989
} catch (NoSuchEntityException $e) {
8090
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
8191
} catch (LocalizedException $e) {

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/UpdateCartItemsTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function testUpdateCartItemQuantity()
7171
$this->assertEquals($itemId, $item['id']);
7272
$this->assertEquals($quantity, $item['quantity']);
7373

74+
//Check that update is correctly reflected in cart
7475
$cartQuery = $this->getCartQuery($maskedQuoteId);
7576
$response = $this->graphQlQuery($cartQuery);
7677

@@ -101,6 +102,15 @@ public function testRemoveCartItemIfQuantityIsZero()
101102

102103
$responseCart = $response['updateCartItems']['cart'];
103104
$this->assertCount(0, $responseCart['items']);
105+
106+
//Check that update is correctly reflected in cart
107+
$cartQuery = $this->getCartQuery($maskedQuoteId);
108+
$response = $this->graphQlQuery($cartQuery);
109+
110+
$this->assertArrayHasKey('cart', $response);
111+
112+
$responseCart = $response['cart'];
113+
$this->assertCount(0, $responseCart['items']);
104114
}
105115

106116
/**

dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/acceptance.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
</allow>
2222
<deny>
2323
<tag group="stable" value="no" />
24+
<tag group="mftf_migrated" value="yes" />
2425
</deny>
2526
</rule>
2627
</config>

lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class ConfigOptionsListConstants
2121
const CONFIG_PATH_CRYPT_KEY = 'crypt/key';
2222
const CONFIG_PATH_SESSION_SAVE = 'session/save';
2323
const CONFIG_PATH_RESOURCE_DEFAULT_SETUP = 'resource/default_setup/connection';
24-
const CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS = 'db/connection/default/driver_options';
2524
const CONFIG_PATH_DB_CONNECTION_DEFAULT = 'db/connection/default';
2625
const CONFIG_PATH_DB_CONNECTIONS = 'db/connection';
2726
const CONFIG_PATH_DB_PREFIX = 'db/table_prefix';
@@ -65,10 +64,6 @@ class ConfigOptionsListConstants
6564
const INPUT_KEY_DB_MODEL = 'db-model';
6665
const INPUT_KEY_DB_INIT_STATEMENTS = 'db-init-statements';
6766
const INPUT_KEY_DB_ENGINE = 'db-engine';
68-
const INPUT_KEY_DB_SSL_KEY = 'db-ssl-key';
69-
const INPUT_KEY_DB_SSL_CERT = 'db-ssl-cert';
70-
const INPUT_KEY_DB_SSL_CA = 'db-ssl-ca';
71-
const INPUT_KEY_DB_SSL_VERIFY = 'db-ssl-verify';
7267
const INPUT_KEY_RESOURCE = 'resource';
7368
const INPUT_KEY_SKIP_DB_VALIDATION = 'skip-db-validation';
7469
const INPUT_KEY_CACHE_HOSTS = 'http-cache-hosts';
@@ -109,20 +104,6 @@ class ConfigOptionsListConstants
109104
const KEY_MODEL = 'model';
110105
const KEY_INIT_STATEMENTS = 'initStatements';
111106
const KEY_ACTIVE = 'active';
112-
const KEY_DRIVER_OPTIONS = 'driver_options';
113-
/**#@-*/
114-
115-
/**#@+
116-
* Array keys for database driver options configurations
117-
*/
118-
const KEY_MYSQL_SSL_KEY = \PDO::MYSQL_ATTR_SSL_KEY;
119-
const KEY_MYSQL_SSL_CERT = \PDO::MYSQL_ATTR_SSL_CERT;
120-
const KEY_MYSQL_SSL_CA = \PDO::MYSQL_ATTR_SSL_CA;
121-
/**
122-
* Constant \PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT cannot be used as it was introduced in PHP 7.1.4
123-
* and Magento 2 is currently supporting PHP 7.1.3.
124-
*/
125-
const KEY_MYSQL_SSL_VERIFY = 1014;
126107
/**#@-*/
127108

128109
/**

setup/src/Magento/Setup/Controller/DatabaseCheck.php

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
namespace Magento\Setup\Controller;
77

8-
use Magento\Framework\Config\ConfigOptionsListConstants;
98
use Magento\Setup\Validator\DbValidator;
109
use Zend\Json\Json;
1110
use Zend\Mvc\Controller\AbstractActionController;
@@ -41,45 +40,12 @@ public function indexAction()
4140
try {
4241
$params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
4342
$password = isset($params['password']) ? $params['password'] : '';
44-
$driverOptions = [];
45-
if ($this->isDriverOptionsGiven($params)) {
46-
if (empty($params['driverOptionsSslVerify'])) {
47-
$params['driverOptionsSslVerify'] = 0;
48-
}
49-
$driverOptions = [
50-
ConfigOptionsListConstants::KEY_MYSQL_SSL_KEY => $params['driverOptionsSslKey'],
51-
ConfigOptionsListConstants::KEY_MYSQL_SSL_CERT => $params['driverOptionsSslCert'],
52-
ConfigOptionsListConstants::KEY_MYSQL_SSL_CA => $params['driverOptionsSslCa'],
53-
ConfigOptionsListConstants::KEY_MYSQL_SSL_VERIFY => (int) $params['driverOptionsSslVerify'],
54-
];
55-
}
56-
$this->dbValidator->checkDatabaseConnectionWithDriverOptions(
57-
$params['name'],
58-
$params['host'],
59-
$params['user'],
60-
$password,
61-
$driverOptions
62-
);
43+
$this->dbValidator->checkDatabaseConnection($params['name'], $params['host'], $params['user'], $password);
6344
$tablePrefix = isset($params['tablePrefix']) ? $params['tablePrefix'] : '';
6445
$this->dbValidator->checkDatabaseTablePrefix($tablePrefix);
6546
return new JsonModel(['success' => true]);
6647
} catch (\Exception $e) {
6748
return new JsonModel(['success' => false, 'error' => $e->getMessage()]);
6849
}
6950
}
70-
71-
/**
72-
* Is Driver Options Given
73-
*
74-
* @param array $params
75-
* @return bool
76-
*/
77-
private function isDriverOptionsGiven($params)
78-
{
79-
return !(
80-
empty($params['driverOptionsSslKey']) ||
81-
empty($params['driverOptionsSslCert']) ||
82-
empty($params['driverOptionsSslCa'])
83-
);
84-
}
8551
}

setup/src/Magento/Setup/Model/ConfigGenerator.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Magento\Framework\Config\ConfigOptionsListConstants;
1515
use Magento\Framework\App\State;
1616
use Magento\Framework\Math\Random;
17-
use Magento\Setup\Model\ConfigOptionsList\DriverOptions;
1817

1918
/**
2019
* Creates deployment config data based on user input array
@@ -63,32 +62,24 @@ class ConfigGenerator
6362
*/
6463
private $cryptKeyGenerator;
6564

66-
/**
67-
* @var DriverOptions
68-
*/
69-
private $driverOptions;
70-
7165
/**
7266
* Constructor
7367
*
7468
* @param Random $random Deprecated since 100.2.0
7569
* @param DeploymentConfig $deploymentConfig
7670
* @param ConfigDataFactory|null $configDataFactory
7771
* @param CryptKeyGeneratorInterface|null $cryptKeyGenerator
78-
* @param DriverOptions|null $driverOptions
7972
*/
8073
public function __construct(
8174
Random $random,
8275
DeploymentConfig $deploymentConfig,
8376
ConfigDataFactory $configDataFactory = null,
84-
CryptKeyGeneratorInterface $cryptKeyGenerator = null,
85-
DriverOptions $driverOptions = null
77+
CryptKeyGeneratorInterface $cryptKeyGenerator = null
8678
) {
8779
$this->random = $random;
8880
$this->deploymentConfig = $deploymentConfig;
8981
$this->configDataFactory = $configDataFactory ?? ObjectManager::getInstance()->get(ConfigDataFactory::class);
9082
$this->cryptKeyGenerator = $cryptKeyGenerator ?? ObjectManager::getInstance()->get(CryptKeyGenerator::class);
91-
$this->driverOptions = $driverOptions ?? ObjectManager::getInstance()->get(DriverOptions::class);
9283
}
9384

9485
/**
@@ -190,9 +181,6 @@ public function createDbConfig(array $data)
190181
$configData->set($dbConnectionPrefix . ConfigOptionsListConstants::KEY_ACTIVE, '1');
191182
}
192183

193-
$driverOptions = $this->driverOptions->getDriverOptions($data);
194-
$configData->set($dbConnectionPrefix . ConfigOptionsListConstants::KEY_DRIVER_OPTIONS, $driverOptions);
195-
196184
return $configData;
197185
}
198186

setup/src/Magento/Setup/Model/ConfigOptionsList.php

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
use Magento\Framework\Encryption\KeyValidator;
1212
use Magento\Framework\Setup\ConfigOptionsListInterface;
1313
use Magento\Framework\Setup\Option\FlagConfigOption;
14-
use Magento\Framework\Setup\Option\SelectConfigOption;
1514
use Magento\Framework\Setup\Option\TextConfigOption;
16-
use Magento\Setup\Model\ConfigOptionsList\DriverOptions;
1715
use Magento\Setup\Validator\DbValidator;
1816

1917
/**
@@ -55,24 +53,17 @@ class ConfigOptionsList implements ConfigOptionsListInterface
5553
\Magento\Setup\Model\ConfigOptionsList\Lock::class,
5654
];
5755

58-
/**
59-
* @var DriverOptions
60-
*/
61-
private $driverOptions;
62-
6356
/**
6457
* Constructor
6558
*
6659
* @param ConfigGenerator $configGenerator
6760
* @param DbValidator $dbValidator
6861
* @param KeyValidator|null $encryptionKeyValidator
69-
* @param DriverOptions|null $driverOptions
7062
*/
7163
public function __construct(
7264
ConfigGenerator $configGenerator,
7365
DbValidator $dbValidator,
74-
KeyValidator $encryptionKeyValidator = null,
75-
DriverOptions $driverOptions = null
66+
KeyValidator $encryptionKeyValidator = null
7667
) {
7768
$this->configGenerator = $configGenerator;
7869
$this->dbValidator = $dbValidator;
@@ -81,7 +72,6 @@ public function __construct(
8172
$this->configOptionsCollection[] = $objectManager->get($className);
8273
}
8374
$this->encryptionKeyValidator = $encryptionKeyValidator ?: $objectManager->get(KeyValidator::class);
84-
$this->driverOptions = $driverOptions ?? $objectManager->get(DriverOptions::class);
8575
}
8676

8777
/**
@@ -172,39 +162,10 @@ public function getOptions()
172162
ConfigOptionsListConstants::CONFIG_PATH_CACHE_HOSTS,
173163
'http Cache hosts'
174164
),
175-
new TextConfigOption(
176-
ConfigOptionsListConstants::INPUT_KEY_DB_SSL_KEY,
177-
TextConfigOption::FRONTEND_WIZARD_TEXT,
178-
ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS .
179-
'/' . ConfigOptionsListConstants::KEY_MYSQL_SSL_KEY,
180-
'Full path of client key file in order to establish db connection through SSL',
181-
null
182-
),
183-
new TextConfigOption(
184-
ConfigOptionsListConstants::INPUT_KEY_DB_SSL_CERT,
185-
TextConfigOption::FRONTEND_WIZARD_TEXT,
186-
ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS .
187-
'/' . ConfigOptionsListConstants::KEY_MYSQL_SSL_CERT,
188-
'Full path of client certificate file in order to establish db connection through SSL',
189-
null
190-
),
191-
new TextConfigOption(
192-
ConfigOptionsListConstants::INPUT_KEY_DB_SSL_CA,
193-
TextConfigOption::FRONTEND_WIZARD_TEXT,
194-
ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS .
195-
'/' . ConfigOptionsListConstants::KEY_MYSQL_SSL_CA,
196-
'Full path of server certificate file in order to establish db connection through SSL',
197-
null
198-
),
199-
new FlagConfigOption(
200-
ConfigOptionsListConstants::INPUT_KEY_DB_SSL_VERIFY,
201-
ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS .
202-
'/' . ConfigOptionsListConstants::KEY_MYSQL_SSL_VERIFY,
203-
'Verify server certification'
204-
),
205165
];
206166

207167
foreach ($this->configOptionsCollection as $configOptionsList) {
168+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
208169
$options = array_merge($options, $configOptionsList->getOptions());
209170
}
210171

@@ -261,6 +222,7 @@ public function validate(array $options, DeploymentConfig $deploymentConfig)
261222
}
262223

263224
foreach ($this->configOptionsCollection as $configOptionsList) {
225+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
264226
$errors = array_merge($errors, $configOptionsList->validate($options, $deploymentConfig));
265227
}
266228

@@ -387,14 +349,12 @@ private function validateDbSettings(array $options, DeploymentConfig $deployment
387349
) {
388350
try {
389351
$options = $this->getDbSettings($options, $deploymentConfig);
390-
$driverOptions = $this->driverOptions->getDriverOptions($options);
391352

392-
$this->dbValidator->checkDatabaseConnectionWithDriverOptions(
353+
$this->dbValidator->checkDatabaseConnection(
393354
$options[ConfigOptionsListConstants::INPUT_KEY_DB_NAME],
394355
$options[ConfigOptionsListConstants::INPUT_KEY_DB_HOST],
395356
$options[ConfigOptionsListConstants::INPUT_KEY_DB_USER],
396-
$options[ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD],
397-
$driverOptions
357+
$options[ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD]
398358
);
399359
} catch (\Exception $exception) {
400360
$errors[] = $exception->getMessage();

0 commit comments

Comments
 (0)