Skip to content

Commit

Permalink
Merge pull request #76 from magento-south/BUGS
Browse files Browse the repository at this point in the history
[South] Bugfixes
  • Loading branch information
dvoskoboinikov committed Jun 4, 2016
2 parents 383362a + ff3138e commit c2bbe72
Show file tree
Hide file tree
Showing 50 changed files with 1,723 additions and 429 deletions.
5 changes: 5 additions & 0 deletions app/code/Magento/Backend/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,9 @@
</arguments>
</type>
<preference for="Magento\Framework\App\Router\PathConfigInterface" type="Magento\Backend\Model\AdminPathConfig" />
<type name="Magento\Framework\View\Page\Config">
<arguments>
<argument name="isIncludesAvailable" xsi:type="boolean">false</argument>
</arguments>
</type>
</config>
48 changes: 48 additions & 0 deletions app/code/Magento/Customer/Controller/Account/CreatePost.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ class CreatePost extends \Magento\Customer\Controller\AbstractAccount
*/
private $accountRedirect;

/**
* @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
*/
private $cookieMetadataFactory;

/**
* @var \Magento\Framework\Stdlib\Cookie\PhpCookieManager
*/
private $cookieMetadataManager;

/**
* @param Context $context
* @param Session $customerSession
Expand Down Expand Up @@ -144,6 +154,38 @@ public function __construct(
parent::__construct($context);
}

/**
* Retrieve cookie manager
*
* @deprecated
* @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager
*/
private function getCookieManager()
{
if (!$this->cookieMetadataManager) {
$this->cookieMetadataManager = \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\Stdlib\Cookie\PhpCookieManager::class
);
}
return $this->cookieMetadataManager;
}

/**
* Retrieve cookie metadata factory
*
* @deprecated
* @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
*/
private function getCookieMetadataFactory()
{
if (!$this->cookieMetadataFactory) {
$this->cookieMetadataFactory = \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class
);
}
return $this->cookieMetadataFactory;
}

/**
* Add address to customer during create account
*
Expand Down Expand Up @@ -267,6 +309,12 @@ public function execute()
}
$resultRedirect = $this->accountRedirect->getRedirect();
}
if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
$metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
$metadata->setPath('/');
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
}

return $resultRedirect;
} catch (StateException $e) {
$url = $this->urlModel->getUrl('customer/account/forgotpassword');
Expand Down
49 changes: 48 additions & 1 deletion app/code/Magento/Customer/Controller/Account/LoginPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ class LoginPost extends \Magento\Customer\Controller\AbstractAccount
*/
private $scopeConfig;

/**
* @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
*/
private $cookieMetadataFactory;

/**
* @var \Magento\Framework\Stdlib\Cookie\PhpCookieManager
*/
private $cookieMetadataManager;

/**
* @param Context $context
* @param Session $customerSession
Expand Down Expand Up @@ -76,13 +86,45 @@ private function getScopeConfig()
{
if (!($this->scopeConfig instanceof \Magento\Framework\App\Config\ScopeConfigInterface)) {
return \Magento\Framework\App\ObjectManager::getInstance()->get(
'Magento\Framework\App\Config\ScopeConfigInterface'
\Magento\Framework\App\Config\ScopeConfigInterface::class
);
} else {
return $this->scopeConfig;
}
}

/**
* Retrieve cookie manager
*
* @deprecated
* @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager
*/
private function getCookieManager()
{
if (!$this->cookieMetadataManager) {
$this->cookieMetadataManager = \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\Stdlib\Cookie\PhpCookieManager::class
);
}
return $this->cookieMetadataManager;
}

/**
* Retrieve cookie metadata factory
*
* @deprecated
* @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
*/
private function getCookieMetadataFactory()
{
if (!$this->cookieMetadataFactory) {
$this->cookieMetadataFactory = \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class
);
}
return $this->cookieMetadataFactory;
}

/**
* Login post action
*
Expand All @@ -105,6 +147,11 @@ public function execute()
$customer = $this->customerAccountManagement->authenticate($login['username'], $login['password']);
$this->session->setCustomerDataAsLoggedIn($customer);
$this->session->regenerateId();
if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
$metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
$metadata->setPath('/');
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
}
$redirectUrl = $this->accountRedirect->getRedirectCookie();
if (!$this->getScopeConfig()->getValue('customer/startup/redirect_dashboard') && $redirectUrl) {
$this->accountRedirect->clearRedirectCookie();
Expand Down
46 changes: 46 additions & 0 deletions app/code/Magento/Customer/Controller/Account/Logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

use Magento\Customer\Model\Session;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
use Magento\Framework\Stdlib\Cookie\PhpCookieManager;

class Logout extends \Magento\Customer\Controller\AbstractAccount
{
Expand All @@ -16,6 +19,16 @@ class Logout extends \Magento\Customer\Controller\AbstractAccount
*/
protected $session;

/**
* @var CookieMetadataFactory
*/
private $cookieMetadataFactory;

/**
* @var PhpCookieManager
*/
private $cookieMetadataManager;

/**
* @param Context $context
* @param Session $customerSession
Expand All @@ -28,6 +41,34 @@ public function __construct(
parent::__construct($context);
}

/**
* Retrieve cookie manager
*
* @deprecated
* @return PhpCookieManager
*/
private function getCookieManager()
{
if (!$this->cookieMetadataManager) {
$this->cookieMetadataManager = ObjectManager::getInstance()->get(PhpCookieManager::class);
}
return $this->cookieMetadataManager;
}

/**
* Retrieve cookie metadata factory
*
* @deprecated
* @return CookieMetadataFactory
*/
private function getCookieMetadataFactory()
{
if (!$this->cookieMetadataFactory) {
$this->cookieMetadataFactory = ObjectManager::getInstance()->get(CookieMetadataFactory::class);
}
return $this->cookieMetadataFactory;
}

/**
* Customer logout action
*
Expand All @@ -38,6 +79,11 @@ public function execute()
$lastCustomerId = $this->session->getId();
$this->session->logout()->setBeforeAuthUrl($this->_redirect->getRefererUrl())
->setLastCustomerId($lastCustomerId);
if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
$metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
$metadata->setPath('/');
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
}

/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
Expand Down
77 changes: 0 additions & 77 deletions app/code/Magento/Customer/Controller/Account/UpdateSession.php

This file was deleted.

8 changes: 3 additions & 5 deletions app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,14 @@ public function execute()
$id = $this->getRequest()->getParam('id');
$resultRedirect = $this->resultRedirectFactory->create();
try {
$customerGroupCode = (string)$this->getRequest()->getParam('code');
if ($id !== null) {
$customerGroup = $this->groupRepository->getById((int)$id);
$customerGroupCode = $customerGroupCode ?: $customerGroup->getCode();
} else {
$customerGroup = $this->groupDataFactory->create();
}
$customerGroupCode = (string)$this->getRequest()->getParam('code');
if (empty($customerGroupCode)) {
$customerGroupCode = null;
}
$customerGroup->setCode($customerGroupCode);
$customerGroup->setCode(!empty($customerGroupCode) ? $customerGroupCode : null);
$customerGroup->setTaxClassId($taxClass);

$this->groupRepository->save($customerGroup);
Expand Down
23 changes: 7 additions & 16 deletions app/code/Magento/Customer/CustomerData/Plugin/SessionChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
*/
namespace Magento\Customer\CustomerData\Plugin;

use Magento\Customer\Model\Session;
use Magento\Framework\App\Response\Http;
use \Magento\Framework\Session\SessionManager;
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
use Magento\Framework\Stdlib\Cookie\PhpCookieManager;

Expand All @@ -22,36 +21,28 @@ class SessionChecker
*/
private $cookieMetadataFactory;

/**
* @var Session
*/
private $session;

/**
* @param PhpCookieManager $cookieManager
* @param CookieMetadataFactory $cookieMetadataFactory
* @param Session $session
*/
public function __construct(
PhpCookieManager $cookieManager,
CookieMetadataFactory $cookieMetadataFactory,
Session $session
CookieMetadataFactory $cookieMetadataFactory
) {
$this->cookieManager = $cookieManager;
$this->cookieMetadataFactory = $cookieMetadataFactory;
$this->session = $session;
}

/**
* Delete frontend session cookie if customer session is expired
*
* @param Http $response
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @return void
* @param SessionManager $sessionManager
*/
public function beforeSendVary(Http $response)
public function beforeStart(SessionManager $sessionManager)
{
if (!$this->session->isLoggedIn()) {
if (!$this->cookieManager->getCookie($sessionManager->getName())
&& $this->cookieManager->getCookie('mage-cache-sessid')
) {
$metadata = $this->cookieMetadataFactory->createCookieMetadata();
$metadata->setPath('/');
$this->cookieManager->deleteCookie('mage-cache-sessid', $metadata);
Expand Down
11 changes: 9 additions & 2 deletions app/code/Magento/Customer/Model/AccountManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,15 @@ public function createAccountWithPasswordHash(CustomerInterface $customer, $hash
}
try {
foreach ($customerAddresses as $address) {
$address->setCustomerId($customer->getId());
$this->addressRepository->save($address);
if ($address->getId()) {
$newAddress = clone $address;
$newAddress->setId(null);
$newAddress->setCustomerId($customer->getId());
$this->addressRepository->save($newAddress);
} else {
$address->setCustomerId($customer->getId());
$this->addressRepository->save($address);
}
}
} catch (InputException $e) {
$this->customerRepository->delete($customer);
Expand Down
Loading

0 comments on commit c2bbe72

Please sign in to comment.