Skip to content

Commit

Permalink
Merge pull request #434 from magento/develop
Browse files Browse the repository at this point in the history
Merge develop into 2002.0
  • Loading branch information
shiftedreality authored Mar 27, 2019
2 parents 4b26fd2 + 541eef8 commit 732771d
Show file tree
Hide file tree
Showing 56 changed files with 1,217 additions and 736 deletions.
13 changes: 1 addition & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,11 @@ addons:
update: true

env:
global:
- DIR_TOOLS="/var/www/ece-tools"
matrix:
- TEST_SUITE=static-unit XDEBUG=true
- TEST_SUITE=integration
- TEST_SUITE=docker-integration

matrix:
exclude:
- php: '7.0'
env: TEST_SUITE=docker-integration
- php: '7.1'
env: TEST_SUITE=docker-integration

cache:
apt: true
directories:
Expand All @@ -41,9 +32,7 @@ before_install:
- echo "COMPOSER_MAGENTO_PASSWORD=${REPO_PASSWORD}" >> ./docker/composer.env
- if [ $XDEBUG == "true" ]; then echo "PHP_ENABLE_XDEBUG=true" >> ./docker/global.env; fi;

install:
- composer update -n --no-suggest
- ./bin/ece-tools docker:build:integration ${TRAVIS_PHP_VERSION} 10.0 latest
install: composer update -n --no-suggest

script: ./tests/travis/script.sh

Expand Down
13 changes: 12 additions & 1 deletion dist/.magento.env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,25 @@
# SCD_COMPRESSION_LEVEL - specifies which gzip compression level (0 to 9) to use when compressing static content; #
# 0 disables compression. #
# Magento Version: 2.1.4 and later #
# Default value: 6 (build stage) or 4 (deploy stage) #
# Default value: 6 (build stage) or 4 (deploy stage) #
# Possible values: from 0 to 9 #
# Stages: global, build and deploy #
# Example: #
# stage: #
# deploy: #
# SCD_COMPRESSION_LEVEL: 5 #
#######################################################################################################################
# SCD_COMPRESSION_TIMEOUT - determine in seconds maximum time for running static compression command #
# by default this value is equal to 600 seconds. #
# Magento Version: 2.1.4 and later #
# Default value: 600 #
# Possible values: > 0 #
# Stages: global, build and deploy #
# Example: #
# stage: #
# deploy: #
# SCD_COMPRESSION_TIMEOUT: 800 #
#######################################################################################################################
# CLEAN_STATIC_FILES - cleans generated static files. By specifying the value of this configuration to 'false', #
# you can leave the static files which were generated during the previous deployment. #
# Magento Version: 2.1.4 and later #
Expand Down
5 changes: 5 additions & 0 deletions patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@
"2.1.5 - 2.1.12": "MAGECLOUD-2820__implement_isolated_connections_mechanism__2.1.5.patch",
"2.1.13 - 2.1.17": "MAGECLOUD-2820__implement_isolated_connections_mechanism__2.1.13.patch",
"2.2.0 - 2.2.8 || 2.3.0 - 2.3.1": "MAGECLOUD-2820__implement_isolated_connections_mechanism__2.2.0.patch"
},
"Pre-auth SQL": {
"2.1.4 - 2.1.17": "MC-5964__preauth_sql__2.1.4.patch",
"2.2.0 - 2.2.7": "MC-5964__preauth_sql__2.2.0.patch",
"2.3.0": "MC-5964__preauth_sql__2.3.0.patch"
}
},
"monolog/monolog": {
Expand Down
12 changes: 12 additions & 0 deletions patches/MC-5964__preauth_sql__2.1.4.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -Naur a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
--- a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
+++ b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
@@ -2955,7 +2955,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];
92 changes: 92 additions & 0 deletions patches/MC-5964__preauth_sql__2.2.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
diff -Naur a/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php b/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
--- a/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
+++ b/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
@@ -138,7 +138,9 @@ private function getProductIdsByActions(array $actions)
$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 @@ public function syncActions(array $productsData, $typeId)
$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 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);
+ }
}
}

diff -Naur a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
index 3d06e27542f0..a6c0dba6e175 100644
--- a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
+++ b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
@@ -2904,7 +2904,7 @@ public function prepareSqlCondition($fieldName, $condition)
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];
123 changes: 123 additions & 0 deletions patches/MC-5964__preauth_sql__2.3.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
diff -Naur a/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php b/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
--- a/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
+++ b/vendor/magento/module-catalog/Model/Product/ProductFrontendAction/Synchronizer.php
@@ -16,6 +16,8 @@
use Magento\Framework\EntityManager\EntityManager;

/**
+ * A Product Widget Synchronizer.
+ *
* Service which allows to sync product widget information, such as product id with db. In order to reuse this info
* on different devices
*/
@@ -85,9 +87,10 @@ public function __construct(
}

/**
- * Find lifetime in configuration. Configuration is hold in Stores Configuration
- * Also this configuration is generated by:
- * @see \Magento\Catalog\Model\Widget\RecentlyViewedStorageConfiguration
+ * Finds lifetime in configuration.
+ *
+ * Configuration is hold in Stores Configuration. Also this configuration is generated by
+ * {@see Magento\Catalog\Model\Widget\RecentlyViewedStorageConfiguration}
*
* @param string $namespace
* @return int
@@ -108,6 +111,8 @@ private function getLifeTimeByNamespace($namespace)
}

/**
+ * Filters actions.
+ *
* In order to avoid suspicious actions, we need to filter them in DESC order, and slice only items that
* can be persisted in database.
*
@@ -138,7 +143,9 @@ private function getProductIdsByActions(array $actions)
$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 +166,37 @@ public function syncActions(array $productsData, $typeId)
$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 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);
+ $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);
+ }
}
}

diff -Naur a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
--- a/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
+++ b/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
@@ -2955,7 +2955,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 changes: 2 additions & 0 deletions src/App/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Magento\MagentoCloud\Command\PostDeploy;
use Magento\MagentoCloud\Config\Database\ConfigInterface;
use Magento\MagentoCloud\Config\Database\MergedConfig;
use Magento\MagentoCloud\Config\Schema;
use Magento\MagentoCloud\Config\Validator as ConfigValidator;
use Magento\MagentoCloud\Config\ValidatorInterface;
use Magento\MagentoCloud\Filesystem\DirectoryCopier;
Expand Down Expand Up @@ -64,6 +65,7 @@ public function __construct(string $toolsBasePath, string $magentoBasePath)
/**
* Binding.
*/
$this->container->singleton(Schema::class);
$this->container->singleton(DirectoryList::class);
$this->container->singleton(FileList::class);
$this->container->singleton(DeployProcess\InstallUpdate\ConfigUpdate\SearchEngine::class);
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Dev/UpdateComposer/ClearModuleRequirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function generate(array $repos)
\$composerJson = json_decode(file_get_contents(\$moduleDir . '/composer.json'), true);
foreach (\$composerJson['require'] as \$requireName => \$requireVersion) {
if (strpos(\$requireName, 'magento/') !== false) {
if (preg_match('{^(magento\/|elasticsearch\/)}i', \$requireName)) {
unset(\$composerJson['require'][\$requireName]);
}
}
Expand Down
Loading

0 comments on commit 732771d

Please sign in to comment.