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

johnpicozzi created an issue. See original summary.

sergei_semipiadniy’s picture

Hi @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!

jigish.addweb’s picture

Status: Active » Needs review
StatusFileSize
new762 bytes

@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.

johnpicozzi’s picture

Version: 8.x-1.0-beta1 » 8.x-1.1
johnpicozzi’s picture

Hello - 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 $domain is 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...

johnpicozzi’s picture

StatusFileSize
new692 bytes

After reviewing the patch closer it looks like we should be checking null on Drupal::request() not Drupal::request()->getPathInfo()

I have updated the patch here and it appears to be working. Thanks for the help!

Status: Needs review » Needs work

The last submitted patch, 6: member_function_error-3013778_6.patch, failed testing. View results

sergei_semipiadniy’s picture

StatusFileSize
new118.27 KB
new1.12 KB

Hi @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!

sergei_semipiadniy’s picture

Status: Needs work » Needs review
johnpicozzi’s picture

@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

itsekhmistro’s picture

Status: Needs review » Fixed

The patch is applied. Thank you all for working on this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.