Loading src/RedirectChecker.php +1 −1 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ class RedirectChecker { // Do not redirect if this is other than GET request. $can_redirect = FALSE; } elseif ($this->state->get('system.maintenance_mode') || defined('MAINTENANCE_MODE')) { elseif (!$this->account->hasPermission('access site in maintenance mode') && ($this->state->get('system.maintenance_mode') || defined('MAINTENANCE_MODE'))) { // Do not redirect in offline or maintenance mode. $can_redirect = FALSE; } Loading tests/src/Unit/RedirectCheckerTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,19 @@ class RedirectCheckerTest extends UnitTestCase { $request = $this->getRequestStub('index.php', 'GET'); $this->assertFalse($checker->canRedirect($request), 'Cannot redirect if maintenance mode is on'); // Maintenance mode is on, but user has access to view site in maintenance mode. $accountWithMaintenanceModeAccess = $this->getMockBuilder('Drupal\Core\Session\AccountInterface') ->getMock(); $accountWithMaintenanceModeAccess->expects($this->any()) ->method('hasPermission') ->with('access site in maintenance mode') ->will($this->returnValue(TRUE)); $checker = new RedirectChecker($this->getConfigFactoryStub($config), $state, $access, $accountWithMaintenanceModeAccess, $route_provider); $request = $this->getRequestStub('index.php', 'GET'); $this->assertTrue($checker->canRedirect($request), 'Redirect should have worked, user has maintenance mode access.'); // We are at a admin path. $state = $this->getMockBuilder('Drupal\Core\State\StateInterface') ->getMock(); Loading Loading
src/RedirectChecker.php +1 −1 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ class RedirectChecker { // Do not redirect if this is other than GET request. $can_redirect = FALSE; } elseif ($this->state->get('system.maintenance_mode') || defined('MAINTENANCE_MODE')) { elseif (!$this->account->hasPermission('access site in maintenance mode') && ($this->state->get('system.maintenance_mode') || defined('MAINTENANCE_MODE'))) { // Do not redirect in offline or maintenance mode. $can_redirect = FALSE; } Loading
tests/src/Unit/RedirectCheckerTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,19 @@ class RedirectCheckerTest extends UnitTestCase { $request = $this->getRequestStub('index.php', 'GET'); $this->assertFalse($checker->canRedirect($request), 'Cannot redirect if maintenance mode is on'); // Maintenance mode is on, but user has access to view site in maintenance mode. $accountWithMaintenanceModeAccess = $this->getMockBuilder('Drupal\Core\Session\AccountInterface') ->getMock(); $accountWithMaintenanceModeAccess->expects($this->any()) ->method('hasPermission') ->with('access site in maintenance mode') ->will($this->returnValue(TRUE)); $checker = new RedirectChecker($this->getConfigFactoryStub($config), $state, $access, $accountWithMaintenanceModeAccess, $route_provider); $request = $this->getRequestStub('index.php', 'GET'); $this->assertTrue($checker->canRedirect($request), 'Redirect should have worked, user has maintenance mode access.'); // We are at a admin path. $state = $this->getMockBuilder('Drupal\Core\State\StateInterface') ->getMock(); Loading