Skip to content

Commit

Permalink
Merge pull request #127 from magento-ogre/develop
Browse files Browse the repository at this point in the history
[Ogre's] Sprint 24 Bugs Contribution
  • Loading branch information
Kopylova,Olga(okopylova) committed Mar 7, 2015
2 parents cdc3d60 + 1606d94 commit 670849f
Show file tree
Hide file tree
Showing 29 changed files with 653 additions and 629 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Grid extends \Magento\Backup\Controller\Adminhtml\Index
*/
public function execute()
{
$this->renderLayot(false);
$this->_view->loadLayout();
$this->_view->renderLayout();
}
}
36 changes: 9 additions & 27 deletions app/code/Magento/Catalog/Model/Layout/DepersonalizePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,17 @@
*/
namespace Magento\Catalog\Model\Layout;

use Magento\PageCache\Model\DepersonalizeChecker;

/**
* Class DepersonalizePlugin
*/
class DepersonalizePlugin
{
/**
* @var \Magento\Framework\App\RequestInterface
*/
protected $request;

/**
* @var \Magento\Framework\Module\Manager
*/
protected $moduleManager;

/**
* @var \Magento\PageCache\Model\Config
* @var DepersonalizeChecker
*/
protected $cacheConfig;
protected $depersonalizeChecker;

/**
* Catalog session
Expand All @@ -35,21 +27,15 @@ class DepersonalizePlugin
protected $catalogSession;

/**
* @param DepersonalizeChecker $depersonalizeChecker
* @param \Magento\Catalog\Model\Session $catalogSession
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\Module\Manager $moduleManager
* @param \Magento\PageCache\Model\Config $cacheConfig
*/
public function __construct(
\Magento\Catalog\Model\Session $catalogSession,
\Magento\Framework\Module\Manager $moduleManager,
\Magento\Framework\App\RequestInterface $request,
\Magento\PageCache\Model\Config $cacheConfig
DepersonalizeChecker $depersonalizeChecker,
\Magento\Catalog\Model\Session $catalogSession
) {
$this->catalogSession = $catalogSession;
$this->request = $request;
$this->moduleManager = $moduleManager;
$this->cacheConfig = $cacheConfig;
$this->depersonalizeChecker = $depersonalizeChecker;
}

/**
Expand All @@ -61,11 +47,7 @@ public function __construct(
*/
public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result)
{
if ($this->moduleManager->isEnabled('Magento_PageCache')
&& $this->cacheConfig->isEnabled()
&& !$this->request->isAjax()
&& $subject->isCacheable()
) {
if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) {
$this->catalogSession->clearStorage();
}
return $result;
Expand Down
41 changes: 11 additions & 30 deletions app/code/Magento/Checkout/Model/Layout/DepersonalizePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,35 @@
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Checkout\Model\Layout;

use Magento\PageCache\Model\DepersonalizeChecker;

/**
* Class DepersonalizePlugin
*/
class DepersonalizePlugin
{
/**
* @var \Magento\Checkout\Model\Session
*/
protected $checkoutSession;

/**
* @var \Magento\Framework\Module\Manager
*/
protected $moduleManager;

/**
* @var \Magento\Framework\App\RequestInterface
* @var DepersonalizeChecker
*/
protected $request;
protected $depersonalizeChecker;

/**
* @var \Magento\PageCache\Model\Config
* @var \Magento\Checkout\Model\Session
*/
protected $cacheConfig;
protected $checkoutSession;

/**
* @param DepersonalizeChecker $depersonalizeChecker
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Framework\Module\Manager $moduleManager
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\PageCache\Model\Config $cacheConfig
*/
public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Framework\Module\Manager $moduleManager,
\Magento\Framework\App\RequestInterface $request,
\Magento\PageCache\Model\Config $cacheConfig
DepersonalizeChecker $depersonalizeChecker,
\Magento\Checkout\Model\Session $checkoutSession
) {
$this->checkoutSession = $checkoutSession;
$this->moduleManager = $moduleManager;
$this->request = $request;
$this->cacheConfig = $cacheConfig;
$this->depersonalizeChecker = $depersonalizeChecker;
}

/**
Expand All @@ -58,11 +43,7 @@ public function __construct(
*/
public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result)
{
if ($this->moduleManager->isEnabled('Magento_PageCache')
&& $this->cacheConfig->isEnabled()
&& !$this->request->isAjax()
&& $subject->isCacheable()
) {
if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) {
$this->checkoutSession->clearStorage();
}
return $result;
Expand Down
47 changes: 13 additions & 34 deletions app/code/Magento/Customer/Model/Layout/DepersonalizePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
*/
namespace Magento\Customer\Model\Layout;

use Magento\PageCache\Model\DepersonalizeChecker;

/**
* Class DepersonalizePlugin
*/
class DepersonalizePlugin
{
/**
* @var DepersonalizeChecker
*/
protected $depersonalizeChecker;

/**
* @var \Magento\Framework\Session\SessionManagerInterface
*/
Expand All @@ -27,16 +34,6 @@ class DepersonalizePlugin
*/
protected $customerFactory;

/**
* @var \Magento\Framework\App\RequestInterface
*/
protected $request;

/**
* @var \Magento\Framework\Module\Manager
*/
protected $moduleManager;

/**
* @var \Magento\Customer\Model\Visitor
*/
Expand All @@ -53,35 +50,24 @@ class DepersonalizePlugin
protected $formKey;

/**
* @var \Magento\PageCache\Model\Config
*/
protected $cacheConfig;

/**
* @param DepersonalizeChecker $depersonalizeChecker
* @param \Magento\Framework\Session\SessionManagerInterface $session
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Customer\Model\CustomerFactory $customerFactory
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\Module\Manager $moduleManager
* @param \Magento\Customer\Model\Visitor $visitor
* @param \Magento\PageCache\Model\Config $cacheConfig
*/
public function __construct(
DepersonalizeChecker $depersonalizeChecker,
\Magento\Framework\Session\SessionManagerInterface $session,
\Magento\Customer\Model\Session $customerSession,
\Magento\Customer\Model\CustomerFactory $customerFactory,
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\Module\Manager $moduleManager,
\Magento\Customer\Model\Visitor $visitor,
\Magento\PageCache\Model\Config $cacheConfig
\Magento\Customer\Model\Visitor $visitor
) {
$this->session = $session;
$this->customerSession = $customerSession;
$this->customerFactory = $customerFactory;
$this->request = $request;
$this->moduleManager = $moduleManager;
$this->visitor = $visitor;
$this->cacheConfig = $cacheConfig;
$this->depersonalizeChecker = $depersonalizeChecker;
}

/**
Expand All @@ -92,10 +78,7 @@ public function __construct(
*/
public function beforeGenerateXml(\Magento\Framework\View\LayoutInterface $subject)
{
if ($this->moduleManager->isEnabled(
'Magento_PageCache'
) && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && $subject->isCacheable()
) {
if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) {
$this->customerGroupId = $this->customerSession->getCustomerGroupId();
$this->formKey = $this->session->getData(\Magento\Framework\Data\Form\FormKey::FORM_KEY);
}
Expand All @@ -111,11 +94,7 @@ public function beforeGenerateXml(\Magento\Framework\View\LayoutInterface $subje
*/
public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result)
{
if ($this->moduleManager->isEnabled('Magento_PageCache')
&& $this->cacheConfig->isEnabled()
&& !$this->request->isAjax()
&& $subject->isCacheable()
) {
if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) {
$this->visitor->setSkipRequestLogging(true);
$this->visitor->unsetData();
$this->session->clearStorage();
Expand Down
63 changes: 63 additions & 0 deletions app/code/Magento/PageCache/Model/DepersonalizeChecker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\PageCache\Model;

/**
* Checks if session should be depersonalized in Depersonalize plugin
*/
class DepersonalizeChecker
{
/**
* Request
*
* @var \Magento\Framework\App\RequestInterface
*/
private $request;

/**
* Module manager
*
* @var \Magento\Framework\Module\Manager
*/
private $moduleManager;

/**
* Cache config
*
* @var Config
*/
private $cacheConfig;

/**
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\Module\Manager $moduleManager
* @param Config $cacheConfig
*/
public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\Module\Manager $moduleManager,
Config $cacheConfig
) {
$this->request = $request;
$this->moduleManager = $moduleManager;
$this->cacheConfig = $cacheConfig;
}

/**
* Check if depersonalize or not
*
* @param \Magento\Framework\View\LayoutInterface $subject
* @return bool
*/
public function checkIfDepersonalize(\Magento\Framework\View\LayoutInterface $subject)
{
return ($this->moduleManager->isEnabled('Magento_PageCache')
&& $this->cacheConfig->isEnabled()
&& !$this->request->isAjax()
&& ($this->request->isGet() || $this->request->isHead())
&& $subject->isCacheable());
}
}
35 changes: 8 additions & 27 deletions app/code/Magento/PageCache/Model/Layout/DepersonalizePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,42 @@
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\PageCache\Model\Layout;

use Magento\PageCache\Model\DepersonalizeChecker;

/**
* Class DepersonalizePlugin
*/
class DepersonalizePlugin
{
/**
* @var \Magento\Framework\App\RequestInterface
*/
protected $request;

/**
* @var \Magento\Framework\Module\Manager
* @var DepersonalizeChecker
*/
protected $moduleManager;
protected $depersonalizeChecker;

/**
* @var \Magento\Framework\Event\Manager
*/
protected $eventManager;

/**
* @var \Magento\PageCache\Model\Config
*/
protected $cacheConfig;

/**
* @var \Magento\Framework\Message\Session
*/
protected $messageSession;

/**
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\Module\Manager $moduleManager
* @param DepersonalizeChecker $depersonalizeChecker
* @param \Magento\Framework\Event\Manager $eventManager
* @param \Magento\PageCache\Model\Config $cacheConfig
* @param \Magento\Framework\Message\Session $messageSession
*/
public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\Module\Manager $moduleManager,
DepersonalizeChecker $depersonalizeChecker,
\Magento\Framework\Event\Manager $eventManager,
\Magento\PageCache\Model\Config $cacheConfig,
\Magento\Framework\Message\Session $messageSession
) {
$this->request = $request;
$this->moduleManager = $moduleManager;
$this->depersonalizeChecker = $depersonalizeChecker;
$this->eventManager = $eventManager;
$this->cacheConfig = $cacheConfig;
$this->messageSession = $messageSession;
}

Expand All @@ -66,11 +51,7 @@ public function __construct(
*/
public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result)
{
if ($this->moduleManager->isEnabled('Magento_PageCache')
&& $this->cacheConfig->isEnabled()
&& !$this->request->isAjax()
&& $subject->isCacheable()
) {
if ($this->depersonalizeChecker->checkIfDepersonalize($subject)) {
$this->eventManager->dispatch('depersonalize_clear_session');
session_write_close();
$this->messageSession->clearStorage();
Expand Down
Loading

0 comments on commit 670849f

Please sign in to comment.