Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 2002.0 into develop #164

Merged
merged 7 commits into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "magento/ece-tools",
"description": "Provides tools to build and deploy Magento 2 Enterprise Edition",
"version": "2002.0.7",
"version": "2002.0.8",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
28 changes: 28 additions & 0 deletions patches.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"colinmollenhour/credis": {
"Fix Redis issue": {
"1.6": "patches/redis-pipeline.patch"
}
},
"magento/framework": {
"Fix locker process": {
"101.0.*": "patches/locker-process.patch"
},
"Remove permissions check": {
"101.0.*": "patches/remove-permission-checks.patch"
},
"Fix redis session locking for 2.2.0 and 2.2.1": {
"101.0.0||101.0.1": "patches/fix-redis-session-manager-locking.patch"
}
},
"magento/module-customer-import-export": {
"Fix out of memory during import of customers and addresses": {
">=100.2.0": "patches/fix-oom-during-import-customers-and-addresses.patch"
}
},
"magento/module-config": {
"Fix app:config:import for Magento 2.2.2": {
"=101.0.2": "patches/fix-app-config-import.patch"
}
}
}
14 changes: 14 additions & 0 deletions patches/fix-app-config-import.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- a/vendor/magento/module-config/Model/Config/Importer.php
+++ b/vendor/magento/module-config/Model/Config/Importer.php
@@ -129,8 +129,10 @@ class Importer implements ImporterInterface

// Invoke saving of new values.
$this->saveProcessor->process($changedData);
- $this->flagManager->saveFlag(static::FLAG_CODE, $data);
});
+
+ $this->scope->setCurrentScope($currentScope);
+ $this->flagManager->saveFlag(static::FLAG_CODE, $data);
} catch (\Exception $e) {
throw new InvalidTransitionException(__('%1', $e->getMessage()), $e);
} finally {
110 changes: 110 additions & 0 deletions patches/fix-oom-during-import-customers-and-addresses.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
commit 4ee8443a262e18c08b942aef313710b2c070a7a4
Author: Viktor Paladiichuk <[email protected]>
Date: Thu Nov 16 18:55:15 2017 +0200

SET-36: Memory limit exhausted during import of customers and addresses

diff --git a/vendor/magento/module-customer-import-export/Model/Import/Address.php b/vendor/magento/module-customer-import-export/Model/Import/Address.php
index eb5742d24c7..70b8c34ef41 100644
--- a/vendor/magento/module-customer-import-export/Model/Import/Address.php
+++ b/vendor/magento/module-customer-import-export/Model/Import/Address.php
@@ -238,6 +238,11 @@ class Address extends AbstractCustomer
protected $postcodeValidator;

/**
+ * @var array
+ */
+ private $loadedAddresses;
+
+ /**
* @param \Magento\Framework\Stdlib\StringUtils $string
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\ImportExport\Model\ImportFactory $importFactory
@@ -368,21 +373,50 @@ class Address extends AbstractCustomer
*/
protected function _initAddresses()
{
- /** @var $address \Magento\Customer\Model\Address */
- foreach ($this->_addressCollection as $address) {
- $customerId = $address->getParentId();
- if (!isset($this->_addresses[$customerId])) {
- $this->_addresses[$customerId] = [];
+ if ($this->_addressCollection->isLoaded()) {
+ /** @var $address \Magento\Customer\Model\Address */
+ foreach ($this->_addressCollection as $address) {
+ $customerId = $address->getParentId();
+ if (!isset($this->_addresses[$customerId])) {
+ $this->_addresses[$customerId] = [];
+ }
+ $addressId = $address->getId();
+ if (!in_array($addressId, $this->_addresses[$customerId])) {
+ $this->_addresses[$customerId][] = $addressId;
+ }
}
- $addressId = $address->getId();
- if (!in_array($addressId, $this->_addresses[$customerId])) {
- $this->_addresses[$customerId][] = $addressId;
+ } else {
+ foreach ($this->getLoadedAddresses() as $addressId => $address) {
+ $customerId = $address['parent_id'];
+ if (!isset($this->_addresses[$customerId])) {
+ $this->_addresses[$customerId] = [];
+ }
+ if (!in_array($addressId, $this->_addresses[$customerId])) {
+ $this->_addresses[$customerId][] = $addressId;
+ }
}
}
return $this;
}

/**
+ * @return array
+ */
+ private function getLoadedAddresses()
+ {
+ if (empty($this->loadedAddresses)) {
+ $collection = clone $this->_addressCollection;
+ $table = $collection->getMainTable();
+ $select = $collection->getSelect();
+ $select->reset('columns');
+ $select->reset('from');
+ $select->from($table, ['entity_id', 'parent_id']);
+ $this->loadedAddresses = $collection->getResource()->getConnection()->fetchAssoc($select);
+ }
+ return $this->loadedAddresses;
+ }
+
+ /**
* Initialize country regions hash for clever recognition
*
* @return $this
diff --git a/vendor/magento/module-customer-import-export/Model/ResourceModel/Import/Customer/Storage.php b/vendor/magento/module-customer-import-export/Model/ResourceModel/Import/Customer/Storage.php
index 4e6687bff28..359822df6d9 100644
--- a/vendor/magento/module-customer-import-export/Model/ResourceModel/Import/Customer/Storage.php
+++ b/vendor/magento/module-customer-import-export/Model/ResourceModel/Import/Customer/Storage.php
@@ -117,13 +117,18 @@ class Storage
*/
public function getCustomerId($email, $websiteId)
{
- // lazy loading
- $this->load();
+ if (!isset($this->_customerIds[$email][$websiteId])) {
+ $collection = clone $this->_customerCollection;
+ $mainTable = $collection->getResource()->getEntityTable();

- if (isset($this->_customerIds[$email][$websiteId])) {
- return $this->_customerIds[$email][$websiteId];
- }
+ $select = $collection->getSelect();
+ $select->reset();
+ $select->from($mainTable, ['entity_id']);
+ $select->where($mainTable . '.email = ?', $email);
+ $select->where($mainTable . '.website_id = ?', $websiteId);

- return false;
+ $this->_customerIds[$email][$websiteId] = $collection->getResource()->getConnection()->fetchOne($select);
+ }
+ return $this->_customerIds[$email][$websiteId];
}
}
24 changes: 24 additions & 0 deletions patches/fix-redis-session-manager-locking.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/vendor/magento/framework/Session/SessionManager.php b/vendor/magento/framework/Session/SessionManager.php
index 2cea02f..272d3d9 100644
--- a/vendor/magento/framework/Session/SessionManager.php
+++ b/vendor/magento/framework/Session/SessionManager.php
@@ -504,18 +504,8 @@ class SessionManager implements SessionManagerInterface
return $this;
}

- //@see http://php.net/manual/en/function.session-regenerate-id.php#53480 workaround
if ($this->isSessionExists()) {
- $oldSessionId = session_id();
- session_regenerate_id();
- $newSessionId = session_id();
- session_id($oldSessionId);
- session_destroy();
-
- $oldSession = $_SESSION;
- session_id($newSessionId);
- session_start();
- $_SESSION = $oldSession;
+ session_regenerate_id(true);
} else {
session_start();
}
76 changes: 76 additions & 0 deletions patches/locker-process.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
MDVA-2470
--- a/vendor/magento/framework/View/Asset/LockerProcess.php 2017-02-13 17:38:15.000000000 +0000
+++ b/vendor/magento/framework/View/Asset/LockerProcess.php 2017-02-13 18:53:22.000000000 +0000
@@ -68,12 +68,26 @@

$this->tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$this->lockFilePath = $this->getFilePath($lockName);
+ $this->waitForLock();

- while ($this->isProcessLocked()) {
- usleep(1000);
+ try {
+ $this->tmpDirectory->writeFile($this->lockFilePath, time(), 'x+');
+ }catch (\Exception $e) {
+ $this->waitForLock();
+ try {
+ $this->tmpDirectory->writeFile($this->lockFilePath, time(), 'x+');
+ }catch (\Exception $e) {
+ throw new \Exception($e->getMessage());
+ }
}

- $this->tmpDirectory->writeFile($this->lockFilePath, time());
+ }
+
+ public function waitForLock()
+ {
+ while ($this->isProcessLocked() ) {
+ usleep(500);
+ }
}

/**
--- a/vendor/magento/framework/View/Asset/PreProcessor/AlternativeSource.php 2017-02-14 20:49:33.000000000 +0000
+++ b/vendor/magento/framework/View/Asset/PreProcessor/AlternativeSource.php 2017-02-15 15:00:41.000000000 +0000
@@ -106,7 +106,7 @@
}

try {
- $this->lockerProcess->lockProcess($this->lockName);
+ $this->lockerProcess->lockProcess($chain->getAsset()->getPath());

$module = $chain->getAsset()->getModule();

--- a/vendor/magento/framework/View/Asset/LockerProcess.php 2017-02-14 21:50:57.000000000 +0000
+++ b/vendor/magento/framework/View/Asset/LockerProcess.php 2017-02-15 15:00:41.000000000 +0000
@@ -67,7 +67,7 @@
}

$this->tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
- $this->lockFilePath = $this->getFilePath($lockName);
+ $this->lockFilePath = $this->getFilePath(str_replace(DIRECTORY_SEPARATOR, '_', $lockName));
$this->waitForLock();

try {
@@ -77,7 +77,8 @@
try {
$this->tmpDirectory->writeFile($this->lockFilePath, time(), 'x+');
}catch (\Exception $e) {
- throw new \Exception($e->getMessage());
+ echo($this->lockFilePath);
+ throw new \Exception("In exception for lock process" . $e->getMessage());
}
}

--- a/vendor/magento/module-developer/Model/View/Asset/PreProcessor/FrontendCompilation.php 2017-02-15 16:24:07.000000000 +0000
+++ b/vendor/magento/module-developer/Model/View/Asset/PreProcessor/FrontendCompilation.php 2017-02-15 16:24:07.000000000 +0000
@@ -76,7 +76,7 @@
{

try {
- $this->lockerProcess->lockProcess($this->lockName);
+ $this->lockerProcess->lockProcess($chain->getAsset()->getPath());

$path = $chain->getAsset()->getFilePath();
$module = $chain->getAsset()->getModule();
12 changes: 12 additions & 0 deletions patches/redis-pipeline.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/vendor/colinmollenhour/credis/Client.php b/vendor/colinmollenhour/credis/Client.php
index afbc85d..8368b32 100755
--- a/vendor/colinmollenhour/credis/Client.php
+++ b/vendor/colinmollenhour/credis/Client.php
@@ -1017,6 +1017,7 @@ class Credis_Client {
} else {
$this->isMulti = TRUE;
$this->redisMulti = call_user_func_array(array($this->redis, $name), $args);
+ return $this;
}
}
else if($name == 'exec' || $name == 'discard') {
43 changes: 43 additions & 0 deletions patches/remove-permission-checks.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff -Naur b/vendor/magento/framework/Setup/FilePermissions.php a/vendor/magento/framework/Setup/FilePermissions.php
--- b/vendor/magento/framework/Setup/FilePermissions.php 2016-09-23 16:01:12.000000000 -0500
+++ a/vendor/magento/framework/Setup/FilePermissions.php 2016-09-23 16:22:09.000000000 -0500
@@ -233,26 +233,8 @@
*/
public function getMissingWritablePathsForInstallation($associative = false)
{
- $required = $this->getInstallationWritableDirectories();
- $current = $this->getInstallationCurrentWritableDirectories();
- $missingPaths = [];
- foreach (array_diff($required, $current) as $missingPath) {
- if (isset($this->nonWritablePathsInDirectories[$missingPath])) {
- if ($associative) {
- $missingPaths[$missingPath] = $this->nonWritablePathsInDirectories[$missingPath];
- } else {
- $missingPaths = array_merge(
- $missingPaths,
- $this->nonWritablePathsInDirectories[$missingPath]
- );
- }
- }
- }
- if ($associative) {
- $required = array_flip($required);
- $missingPaths = array_merge($required, $missingPaths);
- }
- return $missingPaths;
+ // Unnecessary check in controlled environment
+ return [];
}

/**
@@ -275,8 +257,7 @@
*/
public function getUnnecessaryWritableDirectoriesForApplication()
{
- $required = $this->getApplicationNonWritableDirectories();
- $current = $this->getApplicationCurrentNonWritableDirectories();
- return array_diff($required, $current);
+ // Unnecessary check in controlled environment
+ return [];
}
}
5 changes: 4 additions & 1 deletion src/App/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ private function prepare()

$this->file->createDirectory($this->directoryList->getLog());

if ($deployLogFileExists && !$this->isBuildLogApplied($deployLogPath, $buildPhaseLogContent)) {
if ($deployLogFileExists
&& $buildPhaseLogContent
&& !$this->isBuildLogApplied($deployLogPath, $buildPhaseLogContent)
) {
$this->file->filePutContents($deployLogPath, $buildPhaseLogContent, FILE_APPEND);
} elseif (!$deployLogFileExists && $buildLogFileExists) {
$this->file->copy($buildPhaseLogPath, $deployLogPath);
Expand Down
2 changes: 2 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Magento\MagentoCloud;

use Composer\Composer;
use Magento\MagentoCloud\Command\ApplyPatches;
use Magento\MagentoCloud\Command\BackupList;
use Magento\MagentoCloud\Command\BackupRestore;
use Magento\MagentoCloud\Command\Build;
Expand Down Expand Up @@ -65,6 +66,7 @@ protected function getDefaultCommands()
$this->container->get(CronUnlock::class),
$this->container->get(BackupRestore::class),
$this->container->get(BackupList::class),
$this->container->get(ApplyPatches::class),
]
);
}
Expand Down
Loading