From e4e5e2bd1464182223d6a6a396eeeaaf53ac7fd0 Mon Sep 17 00:00:00 2001 From: obaranovskyi Date: Mon, 9 Nov 2015 19:37:01 +0200 Subject: [PATCH 01/15] MAGETWO-45093: Magento-is-stuck-in-Maintenance-mode-if-Backup-is-created-during-disabling-module-via-Web-Setup-Wizard --- lib/internal/Magento/Framework/App/State.php | 10 ++++++++++ .../Magento/Setup/Mvc/Bootstrap/InitParamListener.php | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/App/State.php b/lib/internal/Magento/Framework/App/State.php index 623923371aa83..a588f1fa97a3d 100644 --- a/lib/internal/Magento/Framework/App/State.php +++ b/lib/internal/Magento/Framework/App/State.php @@ -143,6 +143,16 @@ public function getAreaCode() return $this->_areaCode; } + /** + * Check is area code set + * + * @return bool + */ + public function isAreaCodeSet() + { + return !empty($this->_areaCode); + } + /** * Checks whether area code is being emulated * diff --git a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php index 934cc676d2a86..5be437d64d3ef 100644 --- a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php +++ b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php @@ -110,7 +110,9 @@ public function authPreDispatch($event) if ($objectManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) { /** @var \Magento\Framework\App\State $adminAppState */ $adminAppState = $objectManager->get('Magento\Framework\App\State'); - $adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN); + if (!$adminAppState->isAreaCodeSet()) { + $adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN); + } $objectManager->create( 'Magento\Backend\Model\Auth\Session', [ From c47e96fa562a59df3e79e69909242603b640f6eb Mon Sep 17 00:00:00 2001 From: obaranovskyi Date: Tue, 10 Nov 2015 15:02:04 +0200 Subject: [PATCH 02/15] MAGETWO-45093: Magento-is-stuck-in-Maintenance-mode-if-Backup-is-created-during-disabling-module-via-Web-Setup-Wizard - fix after code review --- .../Setup/Mvc/Bootstrap/InitParamListener.php | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php index 5be437d64d3ef..a897dec7880ca 100644 --- a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php +++ b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php @@ -95,13 +95,14 @@ public function onBootstrap(MvcEvent $e) public function authPreDispatch($event) { $controller = $event->getTarget(); + /** @var Application $application */ + $application = $event->getApplication(); if ( + !($application->getRequest() instanceof Request) && !$controller instanceof \Magento\Setup\Controller\Session && !$controller instanceof \Magento\Setup\Controller\Install && !$controller instanceof \Magento\Setup\Controller\Success ) { - /** @var Application $application */ - $application = $event->getApplication(); $serviceManager = $application->getServiceManager(); $objectManagerProvider = $serviceManager->get('Magento\Setup\Model\ObjectManagerProvider'); /** @var \Magento\Framework\ObjectManagerInterface $objectManager */ @@ -112,17 +113,17 @@ public function authPreDispatch($event) $adminAppState = $objectManager->get('Magento\Framework\App\State'); if (!$adminAppState->isAreaCodeSet()) { $adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN); - } - $objectManager->create( - 'Magento\Backend\Model\Auth\Session', - [ - 'sessionConfig' => $objectManager->get('Magento\Backend\Model\Session\AdminConfig'), - 'appState' => $adminAppState - ] - ); - - if (!$objectManager->get('Magento\Backend\Model\Auth')->isLoggedIn()) { - $controller->plugin('redirect')->toUrl('index.php/session/unlogin'); + $objectManager->create( + 'Magento\Backend\Model\Auth\Session', + [ + 'sessionConfig' => $objectManager->get('Magento\Backend\Model\Session\AdminConfig'), + 'appState' => $adminAppState + ] + ); + + if (!$objectManager->get('Magento\Backend\Model\Auth')->isLoggedIn()) { + $controller->plugin('redirect')->toUrl('index.php/session/unlogin'); + } } } } From fb853ac9b7e61057c3ffbc0d5e6864be2b1a7168 Mon Sep 17 00:00:00 2001 From: obaranovskyi Date: Tue, 10 Nov 2015 15:12:23 +0200 Subject: [PATCH 03/15] MAGETWO-45093: Magento-is-stuck-in-Maintenance-mode-if-Backup-is-created-during-disabling-module-via-Web-Setup-Wizard - little fixes --- .../Magento/Setup/Mvc/Bootstrap/InitParamListener.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php index a897dec7880ca..47b1f7535dd62 100644 --- a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php +++ b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php @@ -80,8 +80,10 @@ public function onBootstrap(MvcEvent $e) $serviceManager->setService('Magento\Framework\App\Filesystem\DirectoryList', $directoryList); $serviceManager->setService('Magento\Framework\Filesystem', $this->createFilesystem($directoryList)); - $eventManager = $application->getEventManager(); - $eventManager->attach(MvcEvent::EVENT_DISPATCH, [$this, 'authPreDispatch'], 1); + if (!($application->getRequest() instanceof Request)) { + $eventManager = $application->getEventManager(); + $eventManager->attach(MvcEvent::EVENT_DISPATCH, [$this, 'authPreDispatch'], 1); + } } @@ -95,14 +97,13 @@ public function onBootstrap(MvcEvent $e) public function authPreDispatch($event) { $controller = $event->getTarget(); - /** @var Application $application */ - $application = $event->getApplication(); if ( - !($application->getRequest() instanceof Request) && !$controller instanceof \Magento\Setup\Controller\Session && !$controller instanceof \Magento\Setup\Controller\Install && !$controller instanceof \Magento\Setup\Controller\Success ) { + /** @var Application $application */ + $application = $event->getApplication(); $serviceManager = $application->getServiceManager(); $objectManagerProvider = $serviceManager->get('Magento\Setup\Model\ObjectManagerProvider'); /** @var \Magento\Framework\ObjectManagerInterface $objectManager */ From 9152e778fd80b7e0feee285f92a13cd232d8b920 Mon Sep 17 00:00:00 2001 From: obaranovskyi Date: Tue, 10 Nov 2015 16:15:22 +0200 Subject: [PATCH 04/15] MAGETWO-45208: Session-response-should-be-in-json - fixed --- .../src/Magento/Setup/Controller/Session.php | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/setup/src/Magento/Setup/Controller/Session.php b/setup/src/Magento/Setup/Controller/Session.php index b8c318bad9be1..ca1681af85105 100644 --- a/setup/src/Magento/Setup/Controller/Session.php +++ b/setup/src/Magento/Setup/Controller/Session.php @@ -6,23 +6,32 @@ namespace Magento\Setup\Controller; use Zend\Mvc\Controller\AbstractActionController; -use Magento\Setup\Model\ObjectManagerProvider; +use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; +use Magento\Setup\Model\ObjectManagerProvider; class Session extends AbstractActionController { /** - * @var \Magento\Framework\ObjectManagerInterface + * @var \Zend\ServiceManager\ServiceManager + */ + private $serviceManager; + + /** + * @var \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider */ - private $objectManager; + private $objectManagerProvider; /** + * @param \Zend\ServiceManager\ServiceManager * @param \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider */ public function __construct( + \Zend\ServiceManager\ServiceManager $serviceManager, ObjectManagerProvider $objectManagerProvider ) { - $this->objectManager = $objectManagerProvider->get(); + $this->serviceManager = $serviceManager; + $this->objectManagerProvider = $objectManagerProvider; } /** @@ -33,15 +42,16 @@ public function __construct( public function prolongAction() { try { - if ($this->objectManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) { + if ($this->serviceManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) { + $objectManager = $this->objectManagerProvider->get(); /** @var \Magento\Framework\App\State $adminAppState */ - $adminAppState = $this->objectManager->get('Magento\Framework\App\State'); + $adminAppState = $objectManager->get('Magento\Framework\App\State'); $adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN); /* @var \Magento\Backend\Model\Auth\Session $session */ - $sessionConfig = $this->objectManager->get('Magento\Backend\Model\Session\AdminConfig'); + $sessionConfig = $objectManager->get('Magento\Backend\Model\Session\AdminConfig'); $sessionConfig->setCookiePath('/setup'); - $session = $this->objectManager->create( + $session = $objectManager->create( 'Magento\Backend\Model\Auth\Session', [ 'sessionConfig' => $sessionConfig, @@ -49,11 +59,11 @@ public function prolongAction() ] ); $session->prolong(); - return \Zend_Json::encode(['success' => true]); + return new JsonModel(['success' => true]); } } catch (\Exception $e) { } - return \Zend_Json::encode(['success' => false]); + return new JsonModel(['success' => false]); } /** From 69d8b2d3e5acf88f4fa276fb977684a6232fcbbb Mon Sep 17 00:00:00 2001 From: obaranovskyi Date: Tue, 10 Nov 2015 16:20:56 +0200 Subject: [PATCH 05/15] MAGETWO-45208: Session-response-should-be-in-json - fixed short path to namespace to long --- setup/src/Magento/Setup/Controller/Session.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup/src/Magento/Setup/Controller/Session.php b/setup/src/Magento/Setup/Controller/Session.php index ca1681af85105..0d7b9361db8e5 100644 --- a/setup/src/Magento/Setup/Controller/Session.php +++ b/setup/src/Magento/Setup/Controller/Session.php @@ -8,7 +8,6 @@ use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; -use Magento\Setup\Model\ObjectManagerProvider; class Session extends AbstractActionController { @@ -28,7 +27,7 @@ class Session extends AbstractActionController */ public function __construct( \Zend\ServiceManager\ServiceManager $serviceManager, - ObjectManagerProvider $objectManagerProvider + \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider ) { $this->serviceManager = $serviceManager; $this->objectManagerProvider = $objectManagerProvider; From d13bcc07eaaf70394f039686210d766ea8485428 Mon Sep 17 00:00:00 2001 From: obaranovskyi Date: Tue, 10 Nov 2015 18:59:39 +0200 Subject: [PATCH 06/15] MAGETWO-45093: Magento-is-stuck-in-Maintenance-mode-if-Backup-is-created-during-disabling-module-via-Web-Setup-Wizard - add disabling maintenance mode --- setup/pub/magento/setup/complete-backup.js | 9 ++++++++- setup/src/Magento/Setup/Controller/Maintenance.php | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/setup/pub/magento/setup/complete-backup.js b/setup/pub/magento/setup/complete-backup.js index 5cfc61e8a15c7..70c9ecfd113fb 100644 --- a/setup/pub/magento/setup/complete-backup.js +++ b/setup/pub/magento/setup/complete-backup.js @@ -10,7 +10,7 @@ angular.module('complete-backup', ['ngStorage']) if ($localStorage.backupInfo) { $scope.backupInfoPassed = $localStorage.backupInfo; } - + $scope.type = $state.current.type; $scope.progressCounter = BACKUPCOUNTER; @@ -111,13 +111,20 @@ angular.module('complete-backup', ['ngStorage']) $scope.files = files; $scope.updateOnProcessed($scope.create.responseType); $scope.stopProgress(); + $scope.disableMeintenanceMode(); }, fail: function() { $scope.requestFailedHandler($scope.create); + $scope.disableMeintenanceMode(); } } }; + $scope.disableMeintenanceMode = function() { + $http.post('index.php/maintenance/index', {'disable' : true}).success(function(data) { + }); + }; + $scope.isCompleted = function() { return $scope.maintenance.processed && $scope.check.processed diff --git a/setup/src/Magento/Setup/Controller/Maintenance.php b/setup/src/Magento/Setup/Controller/Maintenance.php index 1bcfdd2af321e..073cfb4389de8 100644 --- a/setup/src/Magento/Setup/Controller/Maintenance.php +++ b/setup/src/Magento/Setup/Controller/Maintenance.php @@ -8,6 +8,7 @@ use Magento\Framework\App\MaintenanceMode; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; +use Zend\Json\Json; class Maintenance extends AbstractActionController { @@ -36,7 +37,9 @@ public function __construct(MaintenanceMode $maintenanceMode) public function indexAction() { try { - $this->maintenanceMode->set(true); + $params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY); + $action = isset($params['disable']) && $params['disable'] ? false : true; + $this->maintenanceMode->set($action); return new JsonModel(['responseType' => ResponseTypeInterface::RESPONSE_TYPE_SUCCESS]); } catch (\Exception $e) { return new JsonModel( From c1f96fddfa5b3d3e19ac28aa9d738c98c8c84e97 Mon Sep 17 00:00:00 2001 From: obaranovskyi Date: Tue, 10 Nov 2015 21:32:11 +0200 Subject: [PATCH 07/15] MAGETWO-45093: Magento-is-stuck-in-Maintenance-mode-if-Backup-is-created-during-disabling-module-via-Web-Setup-Wizard - fixed after bamboo check --- lib/internal/Magento/Framework/App/State.php | 2 +- .../src/Magento/Setup/Controller/Session.php | 2 +- .../Setup/Mvc/Bootstrap/InitParamListener.php | 3 +-- .../Test/Unit/Controller/SessionTest.php | 20 +++++++++++++++---- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/internal/Magento/Framework/App/State.php b/lib/internal/Magento/Framework/App/State.php index a588f1fa97a3d..e85cb87a6baaa 100644 --- a/lib/internal/Magento/Framework/App/State.php +++ b/lib/internal/Magento/Framework/App/State.php @@ -148,7 +148,7 @@ public function getAreaCode() * * @return bool */ - public function isAreaCodeSet() + public function hasAreaCode() { return !empty($this->_areaCode); } diff --git a/setup/src/Magento/Setup/Controller/Session.php b/setup/src/Magento/Setup/Controller/Session.php index 0d7b9361db8e5..60dca02721977 100644 --- a/setup/src/Magento/Setup/Controller/Session.php +++ b/setup/src/Magento/Setup/Controller/Session.php @@ -22,7 +22,7 @@ class Session extends AbstractActionController private $objectManagerProvider; /** - * @param \Zend\ServiceManager\ServiceManager + * @param \Zend\ServiceManager\ServiceManager $serviceManager * @param \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider */ public function __construct( diff --git a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php index 47b1f7535dd62..55c58d688e3d4 100644 --- a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php +++ b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php @@ -86,7 +86,6 @@ public function onBootstrap(MvcEvent $e) } } - /** * Check if user login * @@ -112,7 +111,7 @@ public function authPreDispatch($event) if ($objectManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) { /** @var \Magento\Framework\App\State $adminAppState */ $adminAppState = $objectManager->get('Magento\Framework\App\State'); - if (!$adminAppState->isAreaCodeSet()) { + if (!$adminAppState->hasAreaCode()) { $adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN); $objectManager->create( 'Magento\Backend\Model\Auth\Session', diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php index 7c1eadba29796..4c6efdeefa172 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php @@ -20,13 +20,21 @@ class SessionTest extends \PHPUnit_Framework_TestCase */ private $objectManagerProvider; + /** + * @var \Zend\ServiceManager\ServiceManager + */ + private $serviceManager; + public function setUp() { $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', ['get'], [], '', false); - $objectManagerProvider->expects($this->once())->method('get')->will($this->returnValue($objectManager)); $this->objectManager = $objectManager; $this->objectManagerProvider = $objectManagerProvider; + + $this->serviceManager = $this->getMock( + 'Zend\ServiceManager\ServiceManager', ['get'], [], '', false + ); } /** @@ -34,6 +42,9 @@ public function setUp() */ public function testUnloginAction() { + $this->objectManagerProvider->expects($this->once())->method('get')->will( + $this->returnValue($this->objectManager) + ); $deployConfigMock = $this->getMock('Magento\Framework\App\DeploymentConfig', ['isAvailable'], [], '', false); $deployConfigMock->expects($this->once())->method('isAvailable')->will($this->returnValue(true)); @@ -45,11 +56,12 @@ public function testUnloginAction() $sessionConfigMock->expects($this->once())->method('setCookiePath'); $returnValueMap = [ - ['Magento\Framework\App\DeploymentConfig', $deployConfigMock], ['Magento\Framework\App\State', $stateMock], ['Magento\Backend\Model\Session\AdminConfig', $sessionConfigMock] ]; + $this->serviceManager->expects($this->once())->method('get')->will($this->returnValue($deployConfigMock)); + $this->objectManager->expects($this->atLeastOnce()) ->method('get') ->will($this->returnValueMap($returnValueMap)); @@ -58,7 +70,7 @@ public function testUnloginAction() $this->objectManager->expects($this->once()) ->method('create') ->will($this->returnValue($sessionMock)); - $controller = new Session($this->objectManagerProvider); + $controller = new Session($this->serviceManager, $this->objectManagerProvider); $controller->prolongAction(); } @@ -68,7 +80,7 @@ public function testUnloginAction() public function testIndexAction() { /** @var $controller Session */ - $controller = new Session($this->objectManagerProvider); + $controller = new Session($this->serviceManager, $this->objectManagerProvider); $viewModel = $controller->unloginAction(); $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel); } From 0a7f700e58b8ea09da3b0a4f161118bab48a23fd Mon Sep 17 00:00:00 2001 From: obaranovskyi Date: Wed, 11 Nov 2015 15:32:57 +0200 Subject: [PATCH 08/15] MAGETWO-45093: Magento-is-stuck-in-Maintenance-mode-if-Backup-is-created-during-disabling-module-via-Web-Setup-Wizard - fixed after bamboo check --- setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php index 4c6efdeefa172..efb1773500777 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php @@ -32,9 +32,7 @@ public function setUp() $this->objectManager = $objectManager; $this->objectManagerProvider = $objectManagerProvider; - $this->serviceManager = $this->getMock( - 'Zend\ServiceManager\ServiceManager', ['get'], [], '', false - ); + $this->serviceManager = $this->getMock('Zend\ServiceManager\ServiceManager', ['get'], [], '', false); } /** From 9722a8218059b0b9cd54a569f1a86c9930d1713b Mon Sep 17 00:00:00 2001 From: Ivan Gavryshko Date: Wed, 11 Nov 2015 16:01:16 -0600 Subject: [PATCH 09/15] MAGETWO-45093: Magento is stuck in Maintenance mode if Backup is created during disabling module via Web Setup Wizard - fixed attached event, now it calls before controller and sets area to adminhtml --- lib/internal/Magento/Framework/App/State.php | 10 ---- .../Setup/Mvc/Bootstrap/InitParamListener.php | 56 ++++++++++++------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/lib/internal/Magento/Framework/App/State.php b/lib/internal/Magento/Framework/App/State.php index e85cb87a6baaa..623923371aa83 100644 --- a/lib/internal/Magento/Framework/App/State.php +++ b/lib/internal/Magento/Framework/App/State.php @@ -143,16 +143,6 @@ public function getAreaCode() return $this->_areaCode; } - /** - * Check is area code set - * - * @return bool - */ - public function hasAreaCode() - { - return !empty($this->_areaCode); - } - /** * Checks whether area code is being emulated * diff --git a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php index 95b7fc0f81817..3b358eea7abbc 100644 --- a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php +++ b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php @@ -16,6 +16,7 @@ use Zend\EventManager\ListenerAggregateInterface; use Zend\Mvc\Application; use Zend\Mvc\MvcEvent; +use Zend\Mvc\Router\Http\RouteMatch; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\Stdlib\RequestInterface; @@ -39,6 +40,13 @@ class InitParamListener implements ListenerAggregateInterface, FactoryInterface */ private $listeners = []; + private $controllersToSkip = [ + 'Magento\Setup\Controller\Session', + 'Magento\Setup\Controller\Install', + 'Magento\Setup\Controller\Success' + + ]; + /** * {@inheritdoc} */ @@ -82,7 +90,7 @@ public function onBootstrap(MvcEvent $e) if (!($application->getRequest() instanceof Request)) { $eventManager = $application->getEventManager(); - $eventManager->attach(MvcEvent::EVENT_DISPATCH, [$this, 'authPreDispatch'], 1); + $eventManager->attach(MvcEvent::EVENT_DISPATCH, [$this, 'authPreDispatch'], 100); } } @@ -95,12 +103,11 @@ public function onBootstrap(MvcEvent $e) */ public function authPreDispatch($event) { - $controller = $event->getTarget(); - if ( - !$controller instanceof \Magento\Setup\Controller\Session && - !$controller instanceof \Magento\Setup\Controller\Install && - !$controller instanceof \Magento\Setup\Controller\Success - ) { + /** @var RouteMatch $routeMatch */ + $routeMatch = $event->getRouteMatch(); + $controller = $routeMatch->getParam('controller'); + + if (!in_array($controller, $this->controllersToSkip)) { /** @var Application $application */ $application = $event->getApplication(); $serviceManager = $application->getServiceManager(); @@ -110,19 +117,28 @@ public function authPreDispatch($event) $objectManager = $objectManagerProvider->get(); /** @var \Magento\Framework\App\State $adminAppState */ $adminAppState = $objectManager->get('Magento\Framework\App\State'); - if (!$adminAppState->hasAreaCode()) { - $adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN); - $objectManager->create( - 'Magento\Backend\Model\Auth\Session', - [ - 'sessionConfig' => $objectManager->get('Magento\Backend\Model\Session\AdminConfig'), - 'appState' => $adminAppState - ] - ); - - if (!$objectManager->get('Magento\Backend\Model\Auth')->isLoggedIn()) { - $controller->plugin('redirect')->toUrl('index.php/session/unlogin'); - } + $adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN); + $objectManager->create( + 'Magento\Backend\Model\Auth\Session', + [ + 'sessionConfig' => $objectManager->get('Magento\Backend\Model\Session\AdminConfig'), + 'appState' => $adminAppState + ] + ); + + if (!$objectManager->get('Magento\Backend\Model\Auth')->isLoggedIn()) { + $response=$event->getResponse(); + $response->getHeaders()->addHeaderLine('Location', 'index.php/session/unlogin'); + $response->setStatusCode(302); + $response->sendHeaders(); + + $stopCallBack = function($event) use ($response){ + $event->stopPropagation(); + return $response; + }; + + $application->getEventManager()->attach(MvcEvent::EVENT_ROUTE, $stopCallBack, -10000); + return $response; } } } From 929b4b19a41f467565420ce06a76a2855f9ac55b Mon Sep 17 00:00:00 2001 From: Ivan Gavryshko Date: Wed, 11 Nov 2015 16:42:57 -0600 Subject: [PATCH 10/15] MAGETWO-45093: Magento is stuck in Maintenance mode if Backup is created during disabling module via Web Setup Wizard - moved setArea from Magento\Framework\Setup\BackupRollback to particular places where it calls --- .../Framework/Setup/BackupRollback.php | 18 --------------- .../Setup/Console/Command/BackupCommand.php | 18 +++++++++++++++ .../Setup/Mvc/Bootstrap/InitParamListener.php | 2 +- .../Console/Command/BackupCommandTest.php | 23 ++++++++++++++++++- 4 files changed, 41 insertions(+), 20 deletions(-) diff --git a/lib/internal/Magento/Framework/Setup/BackupRollback.php b/lib/internal/Magento/Framework/Setup/BackupRollback.php index 4b7584f4709be..92b7a12711277 100644 --- a/lib/internal/Magento/Framework/Setup/BackupRollback.php +++ b/lib/internal/Magento/Framework/Setup/BackupRollback.php @@ -197,7 +197,6 @@ public function codeRollback($rollbackFile, $type = Factory::TYPE_FILESYSTEM) */ public function dbBackup($time) { - $this->setAreaCode(); /** @var \Magento\Framework\Backup\Db $dbBackup */ $dbBackup = $this->objectManager->create('Magento\Framework\Backup\Db'); $dbBackup->setRootDir($this->directoryList->getRoot()); @@ -233,7 +232,6 @@ public function dbRollback($rollbackFile) if (!$this->file->isExists($this->backupsDir . '/' . $rollbackFile)) { throw new LocalizedException(new Phrase('The rollback file does not exist.')); } - $this->setAreaCode(); /** @var \Magento\Framework\Backup\Db $dbRollback */ $dbRollback = $this->objectManager->create('Magento\Framework\Backup\Db'); $dbRollback->setRootDir($this->directoryList->getRoot()); @@ -253,22 +251,6 @@ public function dbRollback($rollbackFile) $this->log->logSuccess('DB rollback completed successfully.'); } - /** - * Sets area code to start a session for database backup and rollback - * - * @return void - */ - private function setAreaCode() - { - $areaCode = 'adminhtml'; - /** @var \Magento\Framework\App\State $appState */ - $appState = $this->objectManager->get('Magento\Framework\App\State'); - $appState->setAreaCode($areaCode); - /** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */ - $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); - $this->objectManager->configure($configLoader->load($areaCode)); - } - /** * Get paths that should be excluded during iterative searches for locations for code backup only * diff --git a/setup/src/Magento/Setup/Console/Command/BackupCommand.php b/setup/src/Magento/Setup/Console/Command/BackupCommand.php index e9e6e16fdf5b4..a17241bc4bfd7 100644 --- a/setup/src/Magento/Setup/Console/Command/BackupCommand.php +++ b/setup/src/Magento/Setup/Console/Command/BackupCommand.php @@ -132,6 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $inputOptionProvided = true; } if ($input->getOption(self::INPUT_KEY_DB)) { + $this->setAreaCode(); $backupHandler->dbBackup($time); $inputOptionProvided = true; } @@ -147,4 +148,21 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->maintenanceMode->set(false); } } + + /** + * Sets area code to start a session for database backup and rollback + * + * @return void + */ + private function setAreaCode() + { + $areaCode = 'adminhtml'; + /** @var \Magento\Framework\App\State $appState */ + $appState = $this->objectManager->get('Magento\Framework\App\State'); + $appState->setAreaCode($areaCode); + /** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */ + $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); + $this->objectManager->configure($configLoader->load($areaCode)); + } + } diff --git a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php index 3b358eea7abbc..3a750fa375142 100644 --- a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php +++ b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php @@ -132,7 +132,7 @@ public function authPreDispatch($event) $response->setStatusCode(302); $response->sendHeaders(); - $stopCallBack = function($event) use ($response){ + $stopCallBack = function($event) use ($response) { $event->stopPropagation(); return $response; }; diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/BackupCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/BackupCommandTest.php index 78b4bf38511ab..4ecc35504b24f 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/BackupCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/BackupCommandTest.php @@ -58,9 +58,30 @@ public function setUp() ->method('create') ->willReturn($this->backupRollback); $this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); + $appState = $this->getMock( + 'Magento\Framework\App\State', + [], + [], + '', + false + ); + $configLoader = $this->getMockForAbstractClass( + 'Magento\Framework\ObjectManager\ConfigLoaderInterface', + [], + '', + false + ); + $configLoader->expects($this->any())->method('load')->willReturn([]); + $this->objectManager->expects($this->any()) ->method('get') - ->will($this->returnValue($this->backupRollbackFactory)); + ->will( + $this->returnValueMap([ + ['Magento\Framework\Setup\BackupRollbackFactory', $this->backupRollbackFactory], + ['Magento\Framework\App\State', $appState], + ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], + ]) + ); $command = new BackupCommand( $objectManagerProvider, $maintenanceMode, From 19ae06638d3bd44ab0ef63da0d3745f0a92e051a Mon Sep 17 00:00:00 2001 From: Ivan Gavryshko Date: Wed, 11 Nov 2015 16:56:12 -0600 Subject: [PATCH 11/15] MAGETWO-45093: Magento is stuck in Maintenance mode if Backup is created during disabling module via Web Setup Wizard - added setAreCode to backup commands. --- .../Setup/Console/Command/BackupCommand.php | 1 - .../Console/Command/ModuleUninstallCommand.php | 17 +++++++++++++++++ .../Command/ModuleUninstallCommandTest.php | 8 ++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Console/Command/BackupCommand.php b/setup/src/Magento/Setup/Console/Command/BackupCommand.php index a17241bc4bfd7..622b65e6a92a2 100644 --- a/setup/src/Magento/Setup/Console/Command/BackupCommand.php +++ b/setup/src/Magento/Setup/Console/Command/BackupCommand.php @@ -164,5 +164,4 @@ private function setAreaCode() $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); $this->objectManager->configure($configLoader->load($areaCode)); } - } diff --git a/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php b/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php index c08bfaa1290bd..8d41b82bd8931 100644 --- a/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php @@ -280,6 +280,7 @@ private function takeBackup(InputInterface $input, OutputInterface $output) } if ($input->getOption(self::INPUT_KEY_BACKUP_DB)) { $dbBackup = $this->backupRollbackFactory->create($output); + $this->setAreaCode(); $dbBackup->dbBackup($time); } } @@ -359,4 +360,20 @@ private function checkDependencies(array $modules) } return $messages; } + + /** + * Sets area code to start a session for database backup and rollback + * + * @return void + */ + private function setAreaCode() + { + $areaCode = 'adminhtml'; + /** @var \Magento\Framework\App\State $appState */ + $appState = $this->objectManager->get('Magento\Framework\App\State'); + $appState->setAreaCode($areaCode); + /** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */ + $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); + $this->objectManager->configure($configLoader->load($areaCode)); + } } diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleUninstallCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleUninstallCommandTest.php index 4781cb29badf6..1c2c74b56a0d2 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleUninstallCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleUninstallCommandTest.php @@ -124,6 +124,13 @@ public function setUp() $this->cache = $this->getMock('Magento\Framework\App\Cache', [], [], '', false); $this->cleanupFiles = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false); $objectManagerProvider->expects($this->any())->method('get')->willReturn($objectManager); + $configLoader = $this->getMockForAbstractClass( + 'Magento\Framework\ObjectManager\ConfigLoaderInterface', + [], + '', + false + ); + $configLoader->expects($this->any())->method('load')->willReturn([]); $objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ @@ -133,6 +140,7 @@ public function setUp() ['Magento\Framework\App\State\CleanupFiles', $this->cleanupFiles], ['Magento\Framework\App\State', $this->getMock('Magento\Framework\App\State', [], [], '', false)], ['Magento\Framework\Setup\BackupRollbackFactory', $this->backupRollbackFactory], + ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], ])); $composer = $this->getMock('Magento\Framework\Composer\ComposerInformation', [], [], '', false); $composer->expects($this->any()) From 98fd5b97220a8e568c35a184d9e9a5708a0611cf Mon Sep 17 00:00:00 2001 From: Ivan Gavryshko Date: Wed, 11 Nov 2015 17:20:42 -0600 Subject: [PATCH 12/15] MAGETWO-45093: Magento is stuck in Maintenance mode if Backup is created during disabling module via Web Setup Wizard - added setAreaCode to dbRollback calls --- .../Setup/Console/Command/RollbackCommand.php | 17 +++++++++++++++ .../Magento/Setup/Model/Cron/AbstractJob.php | 12 ++++++++--- .../Setup/Model/Cron/JobDbRollback.php | 17 +++++++++++++++ .../Setup/Mvc/Bootstrap/InitParamListener.php | 7 ++++++- .../Console/Command/RollbackCommandTest.php | 16 ++++++++++++++ .../Unit/Model/Cron/JobDbRollbackTest.php | 21 +++++++++++++++++++ 6 files changed, 86 insertions(+), 4 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/RollbackCommand.php b/setup/src/Magento/Setup/Console/Command/RollbackCommand.php index 13be58d9f73b4..7264138ad08d2 100644 --- a/setup/src/Magento/Setup/Console/Command/RollbackCommand.php +++ b/setup/src/Magento/Setup/Console/Command/RollbackCommand.php @@ -157,6 +157,7 @@ private function doRollback(InputInterface $input, OutputInterface $output) $inputOptionProvided = true; } if ($input->getOption(self::INPUT_KEY_DB_BACKUP_FILE)) { + $this->setAreaCode(); $rollbackHandler->dbRollback($input->getOption(self::INPUT_KEY_DB_BACKUP_FILE)); $inputOptionProvided = true; } @@ -166,4 +167,20 @@ private function doRollback(InputInterface $input, OutputInterface $output) ); } } + + /** + * Sets area code to start a session for database backup and rollback + * + * @return void + */ + private function setAreaCode() + { + $areaCode = 'adminhtml'; + /** @var \Magento\Framework\App\State $appState */ + $appState = $this->objectManager->get('Magento\Framework\App\State'); + $appState->setAreaCode($areaCode); + /** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */ + $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); + $this->objectManager->configure($configLoader->load($areaCode)); + } } diff --git a/setup/src/Magento/Setup/Model/Cron/AbstractJob.php b/setup/src/Magento/Setup/Model/Cron/AbstractJob.php index b6bbec0fdc3dc..735e81c6f116e 100644 --- a/setup/src/Magento/Setup/Model/Cron/AbstractJob.php +++ b/setup/src/Magento/Setup/Model/Cron/AbstractJob.php @@ -7,6 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Magento\Framework\App\Cache; +use Magento\Framework\ObjectManagerInterface; /** * Abstract class for jobs run by setup:cron:run command @@ -48,6 +49,11 @@ abstract class AbstractJob */ protected $status; + /** + * @var ObjectManagerInterface + */ + protected $objectManager; + /** * Constructor @@ -70,9 +76,9 @@ public function __construct( $this->name = $name; $this->params = $params; - $objectManager = $objectManagerProvider->get(); - $this->cleanupFiles = $objectManager->get('Magento\Framework\App\State\CleanupFiles'); - $this->cache = $objectManager->get('Magento\Framework\App\Cache'); + $this->objectManager = $objectManagerProvider->get(); + $this->cleanupFiles = $this->objectManager->get('Magento\Framework\App\State\CleanupFiles'); + $this->cache = $this->objectManager->get('Magento\Framework\App\Cache'); } /** diff --git a/setup/src/Magento/Setup/Model/Cron/JobDbRollback.php b/setup/src/Magento/Setup/Model/Cron/JobDbRollback.php index ffb48a2085d90..5ff8240280be3 100644 --- a/setup/src/Magento/Setup/Model/Cron/JobDbRollback.php +++ b/setup/src/Magento/Setup/Model/Cron/JobDbRollback.php @@ -54,6 +54,7 @@ public function execute() $rollbackHandler = $this->backupRollbackFactory->create($this->output); $dbBackupFile = $this->params['backup_file_name']; if (!empty($dbBackupFile)) { + $this->setAreaCode(); $rollbackHandler->dbRollback(basename($dbBackupFile)); } else { $this->status->add( @@ -70,4 +71,20 @@ public function execute() ); } } + + /** + * Sets area code to start a session for database backup and rollback + * + * @return void + */ + private function setAreaCode() + { + $areaCode = 'adminhtml'; + /** @var \Magento\Framework\App\State $appState */ + $appState = $this->objectManager->get('Magento\Framework\App\State'); + $appState->setAreaCode($areaCode); + /** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */ + $configLoader = $this->objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface'); + $this->objectManager->configure($configLoader->load($areaCode)); + } } diff --git a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php index 3a750fa375142..e8a2944711e78 100644 --- a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php +++ b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php @@ -40,6 +40,11 @@ class InitParamListener implements ListenerAggregateInterface, FactoryInterface */ private $listeners = []; + /** + * List of controllers which should be skipped + * + * @var array + */ private $controllersToSkip = [ 'Magento\Setup\Controller\Session', 'Magento\Setup\Controller\Install', @@ -127,7 +132,7 @@ public function authPreDispatch($event) ); if (!$objectManager->get('Magento\Backend\Model\Auth')->isLoggedIn()) { - $response=$event->getResponse(); + $response = $event->getResponse(); $response->getHeaders()->addHeaderLine('Location', 'index.php/session/unlogin'); $response->setStatusCode(302); $response->sendHeaders(); diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/RollbackCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/RollbackCommandTest.php index 02f9e9956bb57..b94657466c949 100644 --- a/setup/src/Magento/Setup/Test/Unit/Console/Command/RollbackCommandTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/RollbackCommandTest.php @@ -73,10 +73,26 @@ public function setUp() $this->backupRollbackFactory->expects($this->any()) ->method('create') ->willReturn($this->backupRollback); + $appState = $this->getMock( + 'Magento\Framework\App\State', + [], + [], + '', + false + ); + $configLoader = $this->getMockForAbstractClass( + 'Magento\Framework\ObjectManager\ConfigLoaderInterface', + [], + '', + false + ); + $configLoader->expects($this->any())->method('load')->willReturn([]); $this->objectManager->expects($this->any()) ->method('get') ->will($this->returnValueMap([ ['Magento\Framework\Setup\BackupRollbackFactory', $this->backupRollbackFactory], + ['Magento\Framework\App\State', $appState], + ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], ])); $this->helperSet = $this->getMock('Symfony\Component\Console\Helper\HelperSet', [], [], '', false); $this->question = $this->getMock('Symfony\Component\Console\Helper\QuestionHelper', [], [], '', false); diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobDbRollbackTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobDbRollbackTest.php index 0f18eccd1ef82..3c7d57f578916 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobDbRollbackTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobDbRollbackTest.php @@ -48,7 +48,28 @@ public function setup() $output = $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface', [], '', false); $this->objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); + $appState = $this->getMock( + 'Magento\Framework\App\State', + [], + [], + '', + false + ); + $configLoader = $this->getMockForAbstractClass( + 'Magento\Framework\ObjectManager\ConfigLoaderInterface', + [], + '', + false + ); + $configLoader->expects($this->any())->method('load')->willReturn([]); $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false); + $objectManager->expects($this->any()) + ->method('get') + ->will($this->returnValueMap([ + ['Magento\Framework\App\State', $appState], + ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader], + ])); + $this->objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager); $this->jobDbRollback = new JobDbRollback( From 63f7e51bacff08335e49e3eee5db42fba7fce2dd Mon Sep 17 00:00:00 2001 From: Dale Sikkema Date: Wed, 11 Nov 2015 18:16:10 -0600 Subject: [PATCH 13/15] MAGETWO-45159: [ZAP-M2]: Cookie set without secure flag --- app/code/Magento/Backend/Model/Session/AdminConfig.php | 1 + .../Backend/Test/Unit/Model/Session/AdminConfigTest.php | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Backend/Model/Session/AdminConfig.php b/app/code/Magento/Backend/Model/Session/AdminConfig.php index 155a9b09528fc..9dced89caf30d 100644 --- a/app/code/Magento/Backend/Model/Session/AdminConfig.php +++ b/app/code/Magento/Backend/Model/Session/AdminConfig.php @@ -84,6 +84,7 @@ public function __construct( $adminPath = $this->extractAdminPath(); $this->setCookiePath($adminPath); $this->setName($sessionName); + $this->setCookieSecure($this->_httpRequest->isSecure()); } /** diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php index 24baab2a0298e..f66d8bddcaa22 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php @@ -105,12 +105,13 @@ public function testSetCookiePathNonDefault() } /** - * Test for setting session name for admin - * + * Test for setting session name and secure_cookie for admin */ - public function testSetSessionNameByConstructor() + public function testSetSessionSettingsByConstructor() { $sessionName = 'admin'; + $secureRequest = true; + $this->requestMock->expects($this->once())->method('isSecure')->willReturn($secureRequest); $validatorMock = $this->getMockBuilder('Magento\Framework\Validator\ValidatorInterface') ->disableOriginalConstructor() @@ -136,5 +137,6 @@ public function testSetSessionNameByConstructor() ] ); $this->assertSame($sessionName, $adminConfig->getName()); + $this->assertSame($secureRequest, $adminConfig->getCookieSecure()); } } From 921c270f19315de7966df42bba4370252035a777 Mon Sep 17 00:00:00 2001 From: Ivan Gavryshko Date: Wed, 11 Nov 2015 18:20:22 -0600 Subject: [PATCH 14/15] MAGETWO-45093: Magento is stuck in Maintenance mode if Backup is created during disabling module via Web Setup Wizard - CR fixes --- .../Magento/Setup/Model/Cron/JobComponentUninstall.php | 2 +- .../Magento/Setup/Mvc/Bootstrap/InitParamListener.php | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/setup/src/Magento/Setup/Model/Cron/JobComponentUninstall.php b/setup/src/Magento/Setup/Model/Cron/JobComponentUninstall.php index 588ac12881418..7d0e40a956a8d 100644 --- a/setup/src/Magento/Setup/Model/Cron/JobComponentUninstall.php +++ b/setup/src/Magento/Setup/Model/Cron/JobComponentUninstall.php @@ -39,7 +39,7 @@ class JobComponentUninstall extends AbstractJob /** * @var \Magento\Framework\ObjectManagerInterface */ - private $objectManager; + protected $objectManager; /** * @var \Magento\Setup\Model\Updater diff --git a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php index e8a2944711e78..78432801e0fa7 100644 --- a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php +++ b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php @@ -41,7 +41,7 @@ class InitParamListener implements ListenerAggregateInterface, FactoryInterface private $listeners = []; /** - * List of controllers which should be skipped + * List of controllers which should be skipped from auth check * * @var array */ @@ -135,14 +135,8 @@ public function authPreDispatch($event) $response = $event->getResponse(); $response->getHeaders()->addHeaderLine('Location', 'index.php/session/unlogin'); $response->setStatusCode(302); - $response->sendHeaders(); - $stopCallBack = function($event) use ($response) { - $event->stopPropagation(); - return $response; - }; - - $application->getEventManager()->attach(MvcEvent::EVENT_ROUTE, $stopCallBack, -10000); + $event->stopPropagation(); return $response; } } From 809977f4e249c078a95ff533800657cbb06a7d0d Mon Sep 17 00:00:00 2001 From: Dale Sikkema Date: Wed, 11 Nov 2015 18:28:17 -0600 Subject: [PATCH 15/15] MAGETWO-45159: [ZAP-M2]: Cookie set without secure flag --- .../Test/Unit/Model/Session/AdminConfigTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php index f66d8bddcaa22..a521d497fe55e 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php @@ -106,11 +106,12 @@ public function testSetCookiePathNonDefault() /** * Test for setting session name and secure_cookie for admin + * @dataProvider requestSecureDataProvider + * @param $secureRequest */ - public function testSetSessionSettingsByConstructor() + public function testSetSessionSettingsByConstructor($secureRequest) { $sessionName = 'admin'; - $secureRequest = true; $this->requestMock->expects($this->once())->method('isSecure')->willReturn($secureRequest); $validatorMock = $this->getMockBuilder('Magento\Framework\Validator\ValidatorInterface') @@ -139,4 +140,9 @@ public function testSetSessionSettingsByConstructor() $this->assertSame($sessionName, $adminConfig->getName()); $this->assertSame($secureRequest, $adminConfig->getCookieSecure()); } + + public function requestSecureDataProvider() + { + return [[true], [false]]; + } }