-
Require composer-patches:
composer require cweagans/composer-patches -
Add the
patchessection to your composer.json extra field. -
Remove existing packages:
rm -rf vendor/magento/module-catalog vendor/magento/framework -
Run
composer installto re-install and apply patches.
Forked from peterjaap/PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-framework.patch
Last active
April 1, 2019 08:17
-
-
Save barryvdh/8bf1ba88e4a7bfe3ad007de8dbf2600c to your computer and use it in GitHub Desktop.
Magento 2.2 patch for PRODSECBUG-2198 in composer.patches.json format for magento/framework, using `cweagans/composer-patches`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "require": { | |
| "cweagans/composer-patches": "^1" | |
| }, | |
| "extra": { | |
| "patches": { | |
| "magento/framework": { | |
| "PRODSECBUG-2198": "https://gist.github.com/barryvdh/8bf1ba88e4a7bfe3ad007de8dbf2600c/raw/e8d7e0072990cafbcba0e847b20fce62d8793938/PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-framework.patch" | |
| }, | |
| "magento/module-catalog": { | |
| "PRODSECBUG-2198": "https://gist.github.com/barryvdh/8bf1ba88e4a7bfe3ad007de8dbf2600c/raw/e8d7e0072990cafbcba0e847b20fce62d8793938/PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-module-catalog.patch" | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/DB/Adapter/Pdo/Mysql.php b/DB/Adapter/Pdo/Mysql.php | |
| index 1449d6d..38085a3 100644 | |
| --- a/DB/Adapter/Pdo/Mysql.php | |
| +++ b/DB/Adapter/Pdo/Mysql.php | |
| @@ -2904,7 +2904,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface | |
| if (isset($condition['to'])) { | |
| $query .= empty($query) ? '' : ' AND '; | |
| $to = $this->_prepareSqlDateCondition($condition, 'to'); | |
| - $query = $this->_prepareQuotedSqlCondition($query . $conditionKeyMap['to'], $to, $fieldName); | |
| + $query = $query . $this->_prepareQuotedSqlCondition($conditionKeyMap['to'], $to, $fieldName); | |
| } | |
| } elseif (array_key_exists($key, $conditionKeyMap)) { | |
| $value = $condition[$key]; | |
| -- | |
| 2.7.4 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/Model/Product/ProductFrontendAction/Synchronizer.php b/Model/Product/ProductFrontendAction/Synchronizer.php | |
| index 7a1926c..331c667 100644 | |
| --- a/Model/Product/ProductFrontendAction/Synchronizer.php | |
| +++ b/Model/Product/ProductFrontendAction/Synchronizer.php | |
| @@ -138,7 +138,9 @@ class Synchronizer | |
| $productIds = []; | |
| foreach ($actions as $action) { | |
| - $productIds[] = $action['product_id']; | |
| + if (isset($action['product_id']) && is_int($action['product_id'])) { | |
| + $productIds[] = $action['product_id']; | |
| + } | |
| } | |
| return $productIds; | |
| @@ -159,33 +161,37 @@ class Synchronizer | |
| $customerId = $this->session->getCustomerId(); | |
| $visitorId = $this->visitor->getId(); | |
| $collection = $this->getActionsByType($typeId); | |
| - $collection->addFieldToFilter('product_id', $this->getProductIdsByActions($productsData)); | |
| - | |
| - /** | |
| - * Note that collection is also filtered by visitor id and customer id | |
| - * This collection shouldnt be flushed when visitor has products and then login | |
| - * It can remove only products for visitor, or only products for customer | |
| - * | |
| - * ['product_id' => 'added_at'] | |
| - * @var ProductFrontendActionInterface $item | |
| - */ | |
| - foreach ($collection as $item) { | |
| - $this->entityManager->delete($item); | |
| - } | |
| - | |
| - foreach ($productsData as $productId => $productData) { | |
| - /** @var ProductFrontendActionInterface $action */ | |
| - $action = $this->productFrontendActionFactory->create([ | |
| - 'data' => [ | |
| - 'visitor_id' => $customerId ? null : $visitorId, | |
| - 'customer_id' => $this->session->getCustomerId(), | |
| - 'added_at' => $productData['added_at'], | |
| - 'product_id' => $productId, | |
| - 'type_id' => $typeId | |
| - ] | |
| - ]); | |
| - | |
| - $this->entityManager->save($action); | |
| + $productIds = $this->getProductIdsByActions($productsData); | |
| + | |
| + if ($productIds) { | |
| + $collection->addFieldToFilter('product_id', $productIds); | |
| + | |
| + /** | |
| + * Note that collection is also filtered by visitor id and customer id | |
| + * This collection shouldn't be flushed when visitor has products and then login | |
| + * It can remove only products for visitor, or only products for customer | |
| + * | |
| + * ['product_id' => 'added_at'] | |
| + * @var ProductFrontendActionInterface $item | |
| + */ | |
| + foreach ($collection as $item) { | |
| + $this->entityManager->delete($item); | |
| + } | |
| + | |
| + foreach ($productsData as $productId => $productData) { | |
| + /** @var ProductFrontendActionInterface $action */ | |
| + $action = $this->productFrontendActionFactory->create([ | |
| + 'data' => [ | |
| + 'visitor_id' => $customerId ? null : $visitorId, | |
| + 'customer_id' => $this->session->getCustomerId(), | |
| + 'added_at' => $productData['added_at'], | |
| + 'product_id' => $productId, | |
| + 'type_id' => $typeId | |
| + ] | |
| + ]); | |
| + | |
| + $this->entityManager->save($action); | |
| + } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment