Skip to content

Commit 2644086

Browse files
MAGECLOUD-1600: Merge ece-patches into ece-tools (#158)
1 parent a9a9b91 commit 2644086

25 files changed

+1128
-87
lines changed

patches.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"colinmollenhour/credis": {
3+
"Fix Redis issue": {
4+
"1.6": "patches/redis-pipeline.patch"
5+
}
6+
},
7+
"magento/framework": {
8+
"Fix locker process": {
9+
"101.0.*": "patches/locker-process.patch"
10+
},
11+
"Remove permissions check": {
12+
"101.0.*": "patches/remove-permission-checks.patch"
13+
},
14+
"Fix redis session locking for 2.2.0 and 2.2.1": {
15+
"101.0.0||101.0.1": "patches/fix-redis-session-manager-locking.patch"
16+
}
17+
},
18+
"magento/module-customer-import-export": {
19+
"Fix out of memory during import of customers and addresses": {
20+
">=100.2.0": "patches/fix-oom-during-import-customers-and-addresses.patch"
21+
}
22+
},
23+
"magento/module-config": {
24+
"Fix app:config:import for Magento 2.2.2": {
25+
"=101.0.2": "patches/fix-app-config-import.patch"
26+
}
27+
}
28+
}

patches/fix-app-config-import.patch

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- a/vendor/magento/module-config/Model/Config/Importer.php
2+
+++ b/vendor/magento/module-config/Model/Config/Importer.php
3+
@@ -129,8 +129,10 @@ class Importer implements ImporterInterface
4+
5+
// Invoke saving of new values.
6+
$this->saveProcessor->process($changedData);
7+
- $this->flagManager->saveFlag(static::FLAG_CODE, $data);
8+
});
9+
+
10+
+ $this->scope->setCurrentScope($currentScope);
11+
+ $this->flagManager->saveFlag(static::FLAG_CODE, $data);
12+
} catch (\Exception $e) {
13+
throw new InvalidTransitionException(__('%1', $e->getMessage()), $e);
14+
} finally {
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
commit 4ee8443a262e18c08b942aef313710b2c070a7a4
2+
Author: Viktor Paladiichuk <vpaladiychuk@magento.com>
3+
Date: Thu Nov 16 18:55:15 2017 +0200
4+
5+
SET-36: Memory limit exhausted during import of customers and addresses
6+
7+
diff --git a/vendor/magento/module-customer-import-export/Model/Import/Address.php b/vendor/magento/module-customer-import-export/Model/Import/Address.php
8+
index eb5742d24c7..70b8c34ef41 100644
9+
--- a/vendor/magento/module-customer-import-export/Model/Import/Address.php
10+
+++ b/vendor/magento/module-customer-import-export/Model/Import/Address.php
11+
@@ -238,6 +238,11 @@ class Address extends AbstractCustomer
12+
protected $postcodeValidator;
13+
14+
/**
15+
+ * @var array
16+
+ */
17+
+ private $loadedAddresses;
18+
+
19+
+ /**
20+
* @param \Magento\Framework\Stdlib\StringUtils $string
21+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
22+
* @param \Magento\ImportExport\Model\ImportFactory $importFactory
23+
@@ -368,21 +373,50 @@ class Address extends AbstractCustomer
24+
*/
25+
protected function _initAddresses()
26+
{
27+
- /** @var $address \Magento\Customer\Model\Address */
28+
- foreach ($this->_addressCollection as $address) {
29+
- $customerId = $address->getParentId();
30+
- if (!isset($this->_addresses[$customerId])) {
31+
- $this->_addresses[$customerId] = [];
32+
+ if ($this->_addressCollection->isLoaded()) {
33+
+ /** @var $address \Magento\Customer\Model\Address */
34+
+ foreach ($this->_addressCollection as $address) {
35+
+ $customerId = $address->getParentId();
36+
+ if (!isset($this->_addresses[$customerId])) {
37+
+ $this->_addresses[$customerId] = [];
38+
+ }
39+
+ $addressId = $address->getId();
40+
+ if (!in_array($addressId, $this->_addresses[$customerId])) {
41+
+ $this->_addresses[$customerId][] = $addressId;
42+
+ }
43+
}
44+
- $addressId = $address->getId();
45+
- if (!in_array($addressId, $this->_addresses[$customerId])) {
46+
- $this->_addresses[$customerId][] = $addressId;
47+
+ } else {
48+
+ foreach ($this->getLoadedAddresses() as $addressId => $address) {
49+
+ $customerId = $address['parent_id'];
50+
+ if (!isset($this->_addresses[$customerId])) {
51+
+ $this->_addresses[$customerId] = [];
52+
+ }
53+
+ if (!in_array($addressId, $this->_addresses[$customerId])) {
54+
+ $this->_addresses[$customerId][] = $addressId;
55+
+ }
56+
}
57+
}
58+
return $this;
59+
}
60+
61+
/**
62+
+ * @return array
63+
+ */
64+
+ private function getLoadedAddresses()
65+
+ {
66+
+ if (empty($this->loadedAddresses)) {
67+
+ $collection = clone $this->_addressCollection;
68+
+ $table = $collection->getMainTable();
69+
+ $select = $collection->getSelect();
70+
+ $select->reset('columns');
71+
+ $select->reset('from');
72+
+ $select->from($table, ['entity_id', 'parent_id']);
73+
+ $this->loadedAddresses = $collection->getResource()->getConnection()->fetchAssoc($select);
74+
+ }
75+
+ return $this->loadedAddresses;
76+
+ }
77+
+
78+
+ /**
79+
* Initialize country regions hash for clever recognition
80+
*
81+
* @return $this
82+
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
83+
index 4e6687bff28..359822df6d9 100644
84+
--- a/vendor/magento/module-customer-import-export/Model/ResourceModel/Import/Customer/Storage.php
85+
+++ b/vendor/magento/module-customer-import-export/Model/ResourceModel/Import/Customer/Storage.php
86+
@@ -117,13 +117,18 @@ class Storage
87+
*/
88+
public function getCustomerId($email, $websiteId)
89+
{
90+
- // lazy loading
91+
- $this->load();
92+
+ if (!isset($this->_customerIds[$email][$websiteId])) {
93+
+ $collection = clone $this->_customerCollection;
94+
+ $mainTable = $collection->getResource()->getEntityTable();
95+
96+
- if (isset($this->_customerIds[$email][$websiteId])) {
97+
- return $this->_customerIds[$email][$websiteId];
98+
- }
99+
+ $select = $collection->getSelect();
100+
+ $select->reset();
101+
+ $select->from($mainTable, ['entity_id']);
102+
+ $select->where($mainTable . '.email = ?', $email);
103+
+ $select->where($mainTable . '.website_id = ?', $websiteId);
104+
105+
- return false;
106+
+ $this->_customerIds[$email][$websiteId] = $collection->getResource()->getConnection()->fetchOne($select);
107+
+ }
108+
+ return $this->_customerIds[$email][$websiteId];
109+
}
110+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/vendor/magento/framework/Session/SessionManager.php b/vendor/magento/framework/Session/SessionManager.php
2+
index 2cea02f..272d3d9 100644
3+
--- a/vendor/magento/framework/Session/SessionManager.php
4+
+++ b/vendor/magento/framework/Session/SessionManager.php
5+
@@ -504,18 +504,8 @@ class SessionManager implements SessionManagerInterface
6+
return $this;
7+
}
8+
9+
- //@see http://php.net/manual/en/function.session-regenerate-id.php#53480 workaround
10+
if ($this->isSessionExists()) {
11+
- $oldSessionId = session_id();
12+
- session_regenerate_id();
13+
- $newSessionId = session_id();
14+
- session_id($oldSessionId);
15+
- session_destroy();
16+
-
17+
- $oldSession = $_SESSION;
18+
- session_id($newSessionId);
19+
- session_start();
20+
- $_SESSION = $oldSession;
21+
+ session_regenerate_id(true);
22+
} else {
23+
session_start();
24+
}

patches/locker-process.patch

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
MDVA-2470
2+
--- a/vendor/magento/framework/View/Asset/LockerProcess.php 2017-02-13 17:38:15.000000000 +0000
3+
+++ b/vendor/magento/framework/View/Asset/LockerProcess.php 2017-02-13 18:53:22.000000000 +0000
4+
@@ -68,12 +68,26 @@
5+
6+
$this->tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
7+
$this->lockFilePath = $this->getFilePath($lockName);
8+
+ $this->waitForLock();
9+
10+
- while ($this->isProcessLocked()) {
11+
- usleep(1000);
12+
+ try {
13+
+ $this->tmpDirectory->writeFile($this->lockFilePath, time(), 'x+');
14+
+ }catch (\Exception $e) {
15+
+ $this->waitForLock();
16+
+ try {
17+
+ $this->tmpDirectory->writeFile($this->lockFilePath, time(), 'x+');
18+
+ }catch (\Exception $e) {
19+
+ throw new \Exception($e->getMessage());
20+
+ }
21+
}
22+
23+
- $this->tmpDirectory->writeFile($this->lockFilePath, time());
24+
+ }
25+
+
26+
+ public function waitForLock()
27+
+ {
28+
+ while ($this->isProcessLocked() ) {
29+
+ usleep(500);
30+
+ }
31+
}
32+
33+
/**
34+
--- a/vendor/magento/framework/View/Asset/PreProcessor/AlternativeSource.php 2017-02-14 20:49:33.000000000 +0000
35+
+++ b/vendor/magento/framework/View/Asset/PreProcessor/AlternativeSource.php 2017-02-15 15:00:41.000000000 +0000
36+
@@ -106,7 +106,7 @@
37+
}
38+
39+
try {
40+
- $this->lockerProcess->lockProcess($this->lockName);
41+
+ $this->lockerProcess->lockProcess($chain->getAsset()->getPath());
42+
43+
$module = $chain->getAsset()->getModule();
44+
45+
--- a/vendor/magento/framework/View/Asset/LockerProcess.php 2017-02-14 21:50:57.000000000 +0000
46+
+++ b/vendor/magento/framework/View/Asset/LockerProcess.php 2017-02-15 15:00:41.000000000 +0000
47+
@@ -67,7 +67,7 @@
48+
}
49+
50+
$this->tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
51+
- $this->lockFilePath = $this->getFilePath($lockName);
52+
+ $this->lockFilePath = $this->getFilePath(str_replace(DIRECTORY_SEPARATOR, '_', $lockName));
53+
$this->waitForLock();
54+
55+
try {
56+
@@ -77,7 +77,8 @@
57+
try {
58+
$this->tmpDirectory->writeFile($this->lockFilePath, time(), 'x+');
59+
}catch (\Exception $e) {
60+
- throw new \Exception($e->getMessage());
61+
+ echo($this->lockFilePath);
62+
+ throw new \Exception("In exception for lock process" . $e->getMessage());
63+
}
64+
}
65+
66+
--- a/vendor/magento/module-developer/Model/View/Asset/PreProcessor/FrontendCompilation.php 2017-02-15 16:24:07.000000000 +0000
67+
+++ b/vendor/magento/module-developer/Model/View/Asset/PreProcessor/FrontendCompilation.php 2017-02-15 16:24:07.000000000 +0000
68+
@@ -76,7 +76,7 @@
69+
{
70+
71+
try {
72+
- $this->lockerProcess->lockProcess($this->lockName);
73+
+ $this->lockerProcess->lockProcess($chain->getAsset()->getPath());
74+
75+
$path = $chain->getAsset()->getFilePath();
76+
$module = $chain->getAsset()->getModule();

patches/redis-pipeline.patch

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/vendor/colinmollenhour/credis/Client.php b/vendor/colinmollenhour/credis/Client.php
2+
index afbc85d..8368b32 100755
3+
--- a/vendor/colinmollenhour/credis/Client.php
4+
+++ b/vendor/colinmollenhour/credis/Client.php
5+
@@ -1017,6 +1017,7 @@ class Credis_Client {
6+
} else {
7+
$this->isMulti = TRUE;
8+
$this->redisMulti = call_user_func_array(array($this->redis, $name), $args);
9+
+ return $this;
10+
}
11+
}
12+
else if($name == 'exec' || $name == 'discard') {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
diff -Naur b/vendor/magento/framework/Setup/FilePermissions.php a/vendor/magento/framework/Setup/FilePermissions.php
2+
--- b/vendor/magento/framework/Setup/FilePermissions.php 2016-09-23 16:01:12.000000000 -0500
3+
+++ a/vendor/magento/framework/Setup/FilePermissions.php 2016-09-23 16:22:09.000000000 -0500
4+
@@ -233,26 +233,8 @@
5+
*/
6+
public function getMissingWritablePathsForInstallation($associative = false)
7+
{
8+
- $required = $this->getInstallationWritableDirectories();
9+
- $current = $this->getInstallationCurrentWritableDirectories();
10+
- $missingPaths = [];
11+
- foreach (array_diff($required, $current) as $missingPath) {
12+
- if (isset($this->nonWritablePathsInDirectories[$missingPath])) {
13+
- if ($associative) {
14+
- $missingPaths[$missingPath] = $this->nonWritablePathsInDirectories[$missingPath];
15+
- } else {
16+
- $missingPaths = array_merge(
17+
- $missingPaths,
18+
- $this->nonWritablePathsInDirectories[$missingPath]
19+
- );
20+
- }
21+
- }
22+
- }
23+
- if ($associative) {
24+
- $required = array_flip($required);
25+
- $missingPaths = array_merge($required, $missingPaths);
26+
- }
27+
- return $missingPaths;
28+
+ // Unnecessary check in controlled environment
29+
+ return [];
30+
}
31+
32+
/**
33+
@@ -275,8 +257,7 @@
34+
*/
35+
public function getUnnecessaryWritableDirectoriesForApplication()
36+
{
37+
- $required = $this->getApplicationNonWritableDirectories();
38+
- $current = $this->getApplicationCurrentNonWritableDirectories();
39+
- return array_diff($required, $current);
40+
+ // Unnecessary check in controlled environment
41+
+ return [];
42+
}
43+
}

src/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\MagentoCloud;
77

88
use Composer\Composer;
9+
use Magento\MagentoCloud\Command\ApplyPatches;
910
use Magento\MagentoCloud\Command\BackupList;
1011
use Magento\MagentoCloud\Command\BackupRestore;
1112
use Magento\MagentoCloud\Command\Build;
@@ -65,6 +66,7 @@ protected function getDefaultCommands()
6566
$this->container->get(CronUnlock::class),
6667
$this->container->get(BackupRestore::class),
6768
$this->container->get(BackupList::class),
69+
$this->container->get(ApplyPatches::class),
6870
]
6971
);
7072
}

0 commit comments

Comments
 (0)