Skip to content

Commit c2bbe72

Browse files
Merge pull request #76 from magento-south/BUGS
[South] Bugfixes
2 parents 383362a + ff3138e commit c2bbe72

File tree

50 files changed

+1723
-429
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1723
-429
lines changed

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,9 @@
133133
</arguments>
134134
</type>
135135
<preference for="Magento\Framework\App\Router\PathConfigInterface" type="Magento\Backend\Model\AdminPathConfig" />
136+
<type name="Magento\Framework\View\Page\Config">
137+
<arguments>
138+
<argument name="isIncludesAvailable" xsi:type="boolean">false</argument>
139+
</arguments>
140+
</type>
136141
</config>

app/code/Magento/Customer/Controller/Account/CreatePost.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ class CreatePost extends \Magento\Customer\Controller\AbstractAccount
8282
*/
8383
private $accountRedirect;
8484

85+
/**
86+
* @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
87+
*/
88+
private $cookieMetadataFactory;
89+
90+
/**
91+
* @var \Magento\Framework\Stdlib\Cookie\PhpCookieManager
92+
*/
93+
private $cookieMetadataManager;
94+
8595
/**
8696
* @param Context $context
8797
* @param Session $customerSession
@@ -144,6 +154,38 @@ public function __construct(
144154
parent::__construct($context);
145155
}
146156

157+
/**
158+
* Retrieve cookie manager
159+
*
160+
* @deprecated
161+
* @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager
162+
*/
163+
private function getCookieManager()
164+
{
165+
if (!$this->cookieMetadataManager) {
166+
$this->cookieMetadataManager = \Magento\Framework\App\ObjectManager::getInstance()->get(
167+
\Magento\Framework\Stdlib\Cookie\PhpCookieManager::class
168+
);
169+
}
170+
return $this->cookieMetadataManager;
171+
}
172+
173+
/**
174+
* Retrieve cookie metadata factory
175+
*
176+
* @deprecated
177+
* @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
178+
*/
179+
private function getCookieMetadataFactory()
180+
{
181+
if (!$this->cookieMetadataFactory) {
182+
$this->cookieMetadataFactory = \Magento\Framework\App\ObjectManager::getInstance()->get(
183+
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class
184+
);
185+
}
186+
return $this->cookieMetadataFactory;
187+
}
188+
147189
/**
148190
* Add address to customer during create account
149191
*
@@ -267,6 +309,12 @@ public function execute()
267309
}
268310
$resultRedirect = $this->accountRedirect->getRedirect();
269311
}
312+
if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
313+
$metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
314+
$metadata->setPath('/');
315+
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
316+
}
317+
270318
return $resultRedirect;
271319
} catch (StateException $e) {
272320
$url = $this->urlModel->getUrl('customer/account/forgotpassword');

app/code/Magento/Customer/Controller/Account/LoginPost.php

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ class LoginPost extends \Magento\Customer\Controller\AbstractAccount
4242
*/
4343
private $scopeConfig;
4444

45+
/**
46+
* @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
47+
*/
48+
private $cookieMetadataFactory;
49+
50+
/**
51+
* @var \Magento\Framework\Stdlib\Cookie\PhpCookieManager
52+
*/
53+
private $cookieMetadataManager;
54+
4555
/**
4656
* @param Context $context
4757
* @param Session $customerSession
@@ -76,13 +86,45 @@ private function getScopeConfig()
7686
{
7787
if (!($this->scopeConfig instanceof \Magento\Framework\App\Config\ScopeConfigInterface)) {
7888
return \Magento\Framework\App\ObjectManager::getInstance()->get(
79-
'Magento\Framework\App\Config\ScopeConfigInterface'
89+
\Magento\Framework\App\Config\ScopeConfigInterface::class
8090
);
8191
} else {
8292
return $this->scopeConfig;
8393
}
8494
}
8595

96+
/**
97+
* Retrieve cookie manager
98+
*
99+
* @deprecated
100+
* @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager
101+
*/
102+
private function getCookieManager()
103+
{
104+
if (!$this->cookieMetadataManager) {
105+
$this->cookieMetadataManager = \Magento\Framework\App\ObjectManager::getInstance()->get(
106+
\Magento\Framework\Stdlib\Cookie\PhpCookieManager::class
107+
);
108+
}
109+
return $this->cookieMetadataManager;
110+
}
111+
112+
/**
113+
* Retrieve cookie metadata factory
114+
*
115+
* @deprecated
116+
* @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
117+
*/
118+
private function getCookieMetadataFactory()
119+
{
120+
if (!$this->cookieMetadataFactory) {
121+
$this->cookieMetadataFactory = \Magento\Framework\App\ObjectManager::getInstance()->get(
122+
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class
123+
);
124+
}
125+
return $this->cookieMetadataFactory;
126+
}
127+
86128
/**
87129
* Login post action
88130
*
@@ -105,6 +147,11 @@ public function execute()
105147
$customer = $this->customerAccountManagement->authenticate($login['username'], $login['password']);
106148
$this->session->setCustomerDataAsLoggedIn($customer);
107149
$this->session->regenerateId();
150+
if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
151+
$metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
152+
$metadata->setPath('/');
153+
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
154+
}
108155
$redirectUrl = $this->accountRedirect->getRedirectCookie();
109156
if (!$this->getScopeConfig()->getValue('customer/startup/redirect_dashboard') && $redirectUrl) {
110157
$this->accountRedirect->clearRedirectCookie();

app/code/Magento/Customer/Controller/Account/Logout.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
use Magento\Customer\Model\Session;
1010
use Magento\Framework\App\Action\Context;
11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
13+
use Magento\Framework\Stdlib\Cookie\PhpCookieManager;
1114

1215
class Logout extends \Magento\Customer\Controller\AbstractAccount
1316
{
@@ -16,6 +19,16 @@ class Logout extends \Magento\Customer\Controller\AbstractAccount
1619
*/
1720
protected $session;
1821

22+
/**
23+
* @var CookieMetadataFactory
24+
*/
25+
private $cookieMetadataFactory;
26+
27+
/**
28+
* @var PhpCookieManager
29+
*/
30+
private $cookieMetadataManager;
31+
1932
/**
2033
* @param Context $context
2134
* @param Session $customerSession
@@ -28,6 +41,34 @@ public function __construct(
2841
parent::__construct($context);
2942
}
3043

44+
/**
45+
* Retrieve cookie manager
46+
*
47+
* @deprecated
48+
* @return PhpCookieManager
49+
*/
50+
private function getCookieManager()
51+
{
52+
if (!$this->cookieMetadataManager) {
53+
$this->cookieMetadataManager = ObjectManager::getInstance()->get(PhpCookieManager::class);
54+
}
55+
return $this->cookieMetadataManager;
56+
}
57+
58+
/**
59+
* Retrieve cookie metadata factory
60+
*
61+
* @deprecated
62+
* @return CookieMetadataFactory
63+
*/
64+
private function getCookieMetadataFactory()
65+
{
66+
if (!$this->cookieMetadataFactory) {
67+
$this->cookieMetadataFactory = ObjectManager::getInstance()->get(CookieMetadataFactory::class);
68+
}
69+
return $this->cookieMetadataFactory;
70+
}
71+
3172
/**
3273
* Customer logout action
3374
*
@@ -38,6 +79,11 @@ public function execute()
3879
$lastCustomerId = $this->session->getId();
3980
$this->session->logout()->setBeforeAuthUrl($this->_redirect->getRefererUrl())
4081
->setLastCustomerId($lastCustomerId);
82+
if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
83+
$metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
84+
$metadata->setPath('/');
85+
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
86+
}
4187

4288
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
4389
$resultRedirect = $this->resultRedirectFactory->create();

app/code/Magento/Customer/Controller/Account/UpdateSession.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,14 @@ public function execute()
7777
$id = $this->getRequest()->getParam('id');
7878
$resultRedirect = $this->resultRedirectFactory->create();
7979
try {
80+
$customerGroupCode = (string)$this->getRequest()->getParam('code');
8081
if ($id !== null) {
8182
$customerGroup = $this->groupRepository->getById((int)$id);
83+
$customerGroupCode = $customerGroupCode ?: $customerGroup->getCode();
8284
} else {
8385
$customerGroup = $this->groupDataFactory->create();
8486
}
85-
$customerGroupCode = (string)$this->getRequest()->getParam('code');
86-
if (empty($customerGroupCode)) {
87-
$customerGroupCode = null;
88-
}
89-
$customerGroup->setCode($customerGroupCode);
87+
$customerGroup->setCode(!empty($customerGroupCode) ? $customerGroupCode : null);
9088
$customerGroup->setTaxClassId($taxClass);
9189

9290
$this->groupRepository->save($customerGroup);

app/code/Magento/Customer/CustomerData/Plugin/SessionChecker.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
*/
66
namespace Magento\Customer\CustomerData\Plugin;
77

8-
use Magento\Customer\Model\Session;
9-
use Magento\Framework\App\Response\Http;
8+
use \Magento\Framework\Session\SessionManager;
109
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
1110
use Magento\Framework\Stdlib\Cookie\PhpCookieManager;
1211

@@ -22,36 +21,28 @@ class SessionChecker
2221
*/
2322
private $cookieMetadataFactory;
2423

25-
/**
26-
* @var Session
27-
*/
28-
private $session;
29-
3024
/**
3125
* @param PhpCookieManager $cookieManager
3226
* @param CookieMetadataFactory $cookieMetadataFactory
33-
* @param Session $session
3427
*/
3528
public function __construct(
3629
PhpCookieManager $cookieManager,
37-
CookieMetadataFactory $cookieMetadataFactory,
38-
Session $session
30+
CookieMetadataFactory $cookieMetadataFactory
3931
) {
4032
$this->cookieManager = $cookieManager;
4133
$this->cookieMetadataFactory = $cookieMetadataFactory;
42-
$this->session = $session;
4334
}
4435

4536
/**
4637
* Delete frontend session cookie if customer session is expired
4738
*
48-
* @param Http $response
49-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
50-
* @return void
39+
* @param SessionManager $sessionManager
5140
*/
52-
public function beforeSendVary(Http $response)
41+
public function beforeStart(SessionManager $sessionManager)
5342
{
54-
if (!$this->session->isLoggedIn()) {
43+
if (!$this->cookieManager->getCookie($sessionManager->getName())
44+
&& $this->cookieManager->getCookie('mage-cache-sessid')
45+
) {
5546
$metadata = $this->cookieMetadataFactory->createCookieMetadata();
5647
$metadata->setPath('/');
5748
$this->cookieManager->deleteCookie('mage-cache-sessid', $metadata);

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,15 @@ public function createAccountWithPasswordHash(CustomerInterface $customer, $hash
717717
}
718718
try {
719719
foreach ($customerAddresses as $address) {
720-
$address->setCustomerId($customer->getId());
721-
$this->addressRepository->save($address);
720+
if ($address->getId()) {
721+
$newAddress = clone $address;
722+
$newAddress->setId(null);
723+
$newAddress->setCustomerId($customer->getId());
724+
$this->addressRepository->save($newAddress);
725+
} else {
726+
$address->setCustomerId($customer->getId());
727+
$this->addressRepository->save($address);
728+
}
722729
}
723730
} catch (InputException $e) {
724731
$this->customerRepository->delete($customer);

0 commit comments

Comments
 (0)