while adding the Shield module to my site I get the following error.
Error: Call to a member function getPathInfo() on null in country_path_domain_request_alter() (line 158 of modules/contrib/country_path/country_path.module).
country_path_domain_request_alter(Object, NULL, NULL) (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('domain_request', Object) (Line: 120)
Drupal\domain\DomainNegotiator->setRequestDomain('exmple.lndo.site') (Line: 149)
Drupal\domain\DomainNegotiator->negotiateActiveDomain() (Line: 158)
Drupal\domain\DomainNegotiator->getActiveDomain(1) (Line: 200)
Drupal\domain_config\DomainConfigOverrider->initiateContext() (Line: 96)
Drupal\domain_config\DomainConfigOverrider->loadOverrides(Array) (Line: 209)
Drupal\Core\Config\ConfigFactory->loadOverrides(Array) (Line: 169)
Drupal\Core\Config\ConfigFactory->doLoadMultiple(Array, 1) (Line: 104)
Drupal\Core\Config\ConfigFactory->doGet('shield.settings') (Line: 89)
Drupal\Core\Config\ConfigFactory->get('shield.settings') (Line: 58)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 669)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
It renders the site useless and requires a config import to undo the install.
If I add the following if statement before line 158 things work. However, I'm not sure that check is the best solve.
if (!empty($domain->getDomainId())) {
Comments
Comment #2
sergei_semipiadniy commentedHi @johnpicozzi,
You have reported that bug appears on Domain Country Path (8.x-1.0-beta1) on line 158 in country_path.module.
But those version has no line numbered 158.
Could you give me right versions of modules that you are using (shield, country_path, core versoin) ?
It would be great if you attach your composer.json file.
Regards!
Comment #3
jigish.addweb commented@johnpicozzi, This occurs for latest version 8.x-1.x. getPathInfo() gives the extra path information after the URI. So if it is missing it will throw an error. Please find my attached patch that will help you to resolve it.
Comment #4
johnpicozziComment #5
johnpicozziHello - My mistake I tagged this with the wrong version number. I have updated the issue.
The attached patch doesn't resolve the issue. The error now just happens on line 159. It would seem that the
$domainis empty. Not sure if that is normal.I also have the following two patches applied to my module, if that makes a difference.
https://www.drupal.org/files/issues/2018-07-27/country_path-domain_alias...
https://www.drupal.org/files/issues/404-due-to-null-active-domain-294802...
Comment #6
johnpicozziAfter reviewing the patch closer it looks like we should be checking null on
Drupal::request()notDrupal::request()->getPathInfo()I have updated the patch here and it appears to be working. Thanks for the help!
Comment #8
sergei_semipiadniy commentedHi @johnpicozzi,
This bug takes place when we use shield + domain + country_path + domain_config.
Last one is a key for reproducing. If you turn off domain_config all things will be ok.
It happens due to shield's middleware class call config factory, that in it's tern by several steps call "domain_request_alter" functions.
Attached trace will show you the chain.
@johnpicozzi, I think your solution is the best for now. I actualized patch against dev branch with small additions.
Regards!
Comment #9
sergei_semipiadniy commentedComment #10
johnpicozzi@sergei_semipiadniy - Thanks for looking at this. I think you are spot on, my current site has all of those modules enabled. I have tested your patch and it seems to work. RTBC +1
Comment #12
itsekhmistro commentedThe patch is applied. Thank you all for working on this issue.