Skip to content
Snippets Groups Projects
Commit eb438867 authored by Abhishek Gupta's avatar Abhishek Gupta Committed by Ken Rickard
Browse files

Issue #3456056 by abhishek_gupta1, agentrickard, davps: Domain Access: Error:...

Issue #3456056 by abhishek_gupta1, agentrickard, davps: Domain Access: Error: Call to a member function id() on null in Drupal\domain\Access\DomainRouteCheck->access() (line 74 of modules/contrib/domain/domain/src/Access/DomainRouteCheck.php). 
parent b047251b
No related branches found
No related tags found
1 merge request!82fix the issue
Pipeline #213032 passed
......@@ -5,6 +5,7 @@ namespace Drupal\domain\Access;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\domain\DomainInterface;
use Symfony\Component\Routing\Route;
use Drupal\domain\DomainNegotiatorInterface;
......@@ -65,17 +66,23 @@ class DomainRouteCheck implements AccessInterface {
*
* @see \Drupal\domain\Plugin\views\access\Domain
*/
public function access(Route $route, AccountInterface $account) {
// Requirements just allow strings, so this might be a comma separated list.
// Requirements just allow strings, so this might be a comma-separated list.
$string = $route->getRequirement($this->requirementsKey);
$domain = $this->domainNegotiator->getActiveDomain();
// Since only one domain can be active per request, we only suport OR logic.
$allowed = array_filter(array_map('trim', explode('+', $string)));
if (in_array($domain->id(), $allowed, TRUE)) {
return AccessResult::allowed()->addCacheContexts(['url.site']);
// Check if the domain is not null before proceeding.
if ($domain instanceof DomainInterface) {
// Since only one domain can be active per request, we only support OR logic.
$allowed = array_filter(array_map('trim', explode('+', $string)));
if (in_array($domain->id(), $allowed, TRUE)) {
return AccessResult::allowed()->addCacheContexts(['url.site']);
}
}
// If there is no allowed domain, give other access checks a chance.
return AccessResult::neutral()->addCacheContexts(['url.site']);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment