Skip to content

Commit 541eef8

Browse files
MAGECLOUD-3343: Add latest patches to ECE-Tools (#433)
1 parent 34f3c24 commit 541eef8

File tree

4 files changed

+232
-0
lines changed

4 files changed

+232
-0
lines changed

patches.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@
145145
"2.1.5 - 2.1.12": "MAGECLOUD-2820__implement_isolated_connections_mechanism__2.1.5.patch",
146146
"2.1.13 - 2.1.17": "MAGECLOUD-2820__implement_isolated_connections_mechanism__2.1.13.patch",
147147
"2.2.0 - 2.2.8 || 2.3.0 - 2.3.1": "MAGECLOUD-2820__implement_isolated_connections_mechanism__2.2.0.patch"
148+
},
149+
"Pre-auth SQL": {
150+
"2.1.4 - 2.1.17": "MC-5964__preauth_sql__2.1.4.patch",
151+
"2.2.0 - 2.2.7": "MC-5964__preauth_sql__2.2.0.patch",
152+
"2.3.0": "MC-5964__preauth_sql__2.3.0.patch"
148153
}
149154
},
150155
"monolog/monolog": {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff -Naur a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
2+
--- a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
3+
+++ b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
4+
@@ -2955,7 +2955,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface
5+
if (isset($condition['to'])) {
6+
$query .= empty($query) ? '' : ' AND ';
7+
$to = $this->_prepareSqlDateCondition($condition, 'to');
8+
- $query = $this->_prepareQuotedSqlCondition($query . $conditionKeyMap['to'], $to, $fieldName);
9+
+ $query = $query . $this->_prepareQuotedSqlCondition($conditionKeyMap['to'], $to, $fieldName);
10+
}
11+
} elseif (array_key_exists($key, $conditionKeyMap)) {
12+
$value = $condition[$key];
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
diff -Naur a/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php b/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
2+
--- a/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
3+
+++ b/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
4+
@@ -138,7 +138,9 @@ private function getProductIdsByActions(array $actions)
5+
$productIds = [];
6+
7+
foreach ($actions as $action) {
8+
- $productIds[] = $action['product_id'];
9+
+ if (isset($action['product_id']) && is_int($action['product_id'])) {
10+
+ $productIds[] = $action['product_id'];
11+
+ }
12+
}
13+
14+
return $productIds;
15+
@@ -159,33 +161,37 @@ public function syncActions(array $productsData, $typeId)
16+
$customerId = $this->session->getCustomerId();
17+
$visitorId = $this->visitor->getId();
18+
$collection = $this->getActionsByType($typeId);
19+
- $collection->addFieldToFilter('product_id', $this->getProductIdsByActions($productsData));
20+
-
21+
- /**
22+
- * Note that collection is also filtered by visitor id and customer id
23+
- * This collection shouldnt be flushed when visitor has products and then login
24+
- * It can remove only products for visitor, or only products for customer
25+
- *
26+
- * ['product_id' => 'added_at']
27+
- * @var ProductFrontendActionInterface $item
28+
- */
29+
- foreach ($collection as $item) {
30+
- $this->entityManager->delete($item);
31+
- }
32+
-
33+
- foreach ($productsData as $productId => $productData) {
34+
- /** @var ProductFrontendActionInterface $action */
35+
- $action = $this->productFrontendActionFactory->create([
36+
- 'data' => [
37+
- 'visitor_id' => $customerId ? null : $visitorId,
38+
- 'customer_id' => $this->session->getCustomerId(),
39+
- 'added_at' => $productData['added_at'],
40+
- 'product_id' => $productId,
41+
- 'type_id' => $typeId
42+
- ]
43+
- ]);
44+
-
45+
- $this->entityManager->save($action);
46+
+ $productIds = $this->getProductIdsByActions($productsData);
47+
+
48+
+ if ($productIds) {
49+
+ $collection->addFieldToFilter('product_id', $productIds);
50+
+
51+
+ /**
52+
+ * Note that collection is also filtered by visitor id and customer id
53+
+ * This collection shouldnt be flushed when visitor has products and then login
54+
+ * It can remove only products for visitor, or only products for customer
55+
+ *
56+
+ * ['product_id' => 'added_at']
57+
+ * @var ProductFrontendActionInterface $item
58+
+ */
59+
+ foreach ($collection as $item) {
60+
+ $this->entityManager->delete($item);
61+
+ }
62+
+
63+
+ foreach ($productsData as $productId => $productData) {
64+
+ /** @var ProductFrontendActionInterface $action */
65+
+ $action = $this->productFrontendActionFactory->create([
66+
+ 'data' => [
67+
+ 'visitor_id' => $customerId ? null : $visitorId,
68+
+ 'customer_id' => $this->session->getCustomerId(),
69+
+ 'added_at' => $productData['added_at'],
70+
+ 'product_id' => $productId,
71+
+ 'type_id' => $typeId
72+
+ ]
73+
+ ]);
74+
+
75+
+ $this->entityManager->save($action);
76+
+ }
77+
}
78+
}
79+
80+
diff -Naur a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
81+
index 3d06e27542f0..a6c0dba6e175 100644
82+
--- a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
83+
+++ b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
84+
@@ -2904,7 +2904,7 @@ public function prepareSqlCondition($fieldName, $condition)
85+
if (isset($condition['to'])) {
86+
$query .= empty($query) ? '' : ' AND ';
87+
$to = $this->_prepareSqlDateCondition($condition, 'to');
88+
- $query = $this->_prepareQuotedSqlCondition($query . $conditionKeyMap['to'], $to, $fieldName);
89+
+ $query = $query . $this->_prepareQuotedSqlCondition($conditionKeyMap['to'], $to, $fieldName);
90+
}
91+
} elseif (array_key_exists($key, $conditionKeyMap)) {
92+
$value = $condition[$key];
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
diff -Naur a/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php b/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
2+
--- a/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
3+
+++ b/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
4+
@@ -16,6 +16,8 @@
5+
use Magento\Framework\EntityManager\EntityManager;
6+
7+
/**
8+
+ * A Product Widget Synchronizer.
9+
+ *
10+
* Service which allows to sync product widget information, such as product id with db. In order to reuse this info
11+
* on different devices
12+
*/
13+
@@ -85,9 +87,10 @@ public function __construct(
14+
}
15+
16+
/**
17+
- * Find lifetime in configuration. Configuration is hold in Stores Configuration
18+
- * Also this configuration is generated by:
19+
- * @see \Magento\Catalog\Model\Widget\RecentlyViewedStorageConfiguration
20+
+ * Finds lifetime in configuration.
21+
+ *
22+
+ * Configuration is hold in Stores Configuration. Also this configuration is generated by
23+
+ * {@see Magento\Catalog\Model\Widget\RecentlyViewedStorageConfiguration}
24+
*
25+
* @param string $namespace
26+
* @return int
27+
@@ -108,6 +111,8 @@ private function getLifeTimeByNamespace($namespace)
28+
}
29+
30+
/**
31+
+ * Filters actions.
32+
+ *
33+
* In order to avoid suspicious actions, we need to filter them in DESC order, and slice only items that
34+
* can be persisted in database.
35+
*
36+
@@ -138,7 +143,9 @@ private function getProductIdsByActions(array $actions)
37+
$productIds = [];
38+
39+
foreach ($actions as $action) {
40+
- $productIds[] = $action['product_id'];
41+
+ if (isset($action['product_id']) && is_int($action['product_id'])) {
42+
+ $productIds[] = $action['product_id'];
43+
+ }
44+
}
45+
46+
return $productIds;
47+
@@ -159,33 +166,37 @@ public function syncActions(array $productsData, $typeId)
48+
$customerId = $this->session->getCustomerId();
49+
$visitorId = $this->visitor->getId();
50+
$collection = $this->getActionsByType($typeId);
51+
- $collection->addFieldToFilter('product_id', $this->getProductIdsByActions($productsData));
52+
-
53+
- /**
54+
- * Note that collection is also filtered by visitor id and customer id
55+
- * This collection shouldn't be flushed when visitor has products and then login
56+
- * It can remove only products for visitor, or only products for customer
57+
- *
58+
- * ['product_id' => 'added_at']
59+
- * @var ProductFrontendActionInterface $item
60+
- */
61+
- foreach ($collection as $item) {
62+
- $this->entityManager->delete($item);
63+
- }
64+
-
65+
- foreach ($productsData as $productId => $productData) {
66+
- /** @var ProductFrontendActionInterface $action */
67+
- $action = $this->productFrontendActionFactory->create([
68+
- 'data' => [
69+
- 'visitor_id' => $customerId ? null : $visitorId,
70+
- 'customer_id' => $this->session->getCustomerId(),
71+
- 'added_at' => $productData['added_at'],
72+
- 'product_id' => $productId,
73+
- 'type_id' => $typeId
74+
- ]
75+
- ]);
76+
-
77+
- $this->entityManager->save($action);
78+
+ $productIds = $this->getProductIdsByActions($productsData);
79+
+
80+
+ if ($productIds) {
81+
+ $collection->addFieldToFilter('product_id', $productIds);
82+
+
83+
+ /**
84+
+ * Note that collection is also filtered by visitor id and customer id
85+
+ * This collection shouldn't be flushed when visitor has products and then login
86+
+ * It can remove only products for visitor, or only products for customer
87+
+ *
88+
+ * ['product_id' => 'added_at']
89+
+ * @var ProductFrontendActionInterface $item
90+
+ */
91+
+ foreach ($collection as $item) {
92+
+ $this->entityManager->delete($item);
93+
+ }
94+
+
95+
+ foreach ($productsData as $productId => $productData) {
96+
+ /** @var ProductFrontendActionInterface $action */
97+
+ $action = $this->productFrontendActionFactory->create([
98+
+ 'data' => [
99+
+ 'visitor_id' => $customerId ? null : $visitorId,
100+
+ 'customer_id' => $this->session->getCustomerId(),
101+
+ 'added_at' => $productData['added_at'],
102+
+ 'product_id' => $productId,
103+
+ 'type_id' => $typeId
104+
+ ]
105+
+ ]);
106+
+
107+
+ $this->entityManager->save($action);
108+
+ }
109+
}
110+
}
111+
112+
diff -Naur a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
113+
--- a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
114+
+++ b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
115+
@@ -2955,7 +2955,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface
116+
if (isset($condition['to'])) {
117+
$query .= empty($query) ? '' : ' AND ';
118+
$to = $this->_prepareSqlDateCondition($condition, 'to');
119+
- $query = $this->_prepareQuotedSqlCondition($query . $conditionKeyMap['to'], $to, $fieldName);
120+
+ $query = $query . $this->_prepareQuotedSqlCondition($conditionKeyMap['to'], $to, $fieldName);
121+
}
122+
} elseif (array_key_exists($key, $conditionKeyMap)) {
123+
$value = $condition[$key];

0 commit comments

Comments
 (0)