Drupal Version

10.5.4

Domain module version

This is happening when I upgrade from beta6 to beta7.

Issue Described

I've since rolled back my version back to beta6 and all is working as expected.

The issue is I have two domains I'll refer to as domainA and domainB. When I go to domainA I see the correct front page and when I go to domainB on either test or live (on a pantheon site) I get redirected to domainA. This issue does not present itself locally or in any other environments like dev or a multidev instance. I also notice if I clear the cache and go straight to domainB, that homepage loads as expected and then I go to domainA it redirects me to domainB.

The front pages are setup using the `domain_config` module under Basic Site Settings `admin/config/system/site-information`.

Issue fork domain-3555807

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

protitude created an issue. See original summary.

mably’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

Could you provide a full reproducible scenario from a fresh Drupal instance please?

I haven't been able to reproduce the problem locally.

protitude’s picture

StatusFileSize
new863 bytes

Sorry, but I can't get this to break anywhere but on pantheon test and live environments which leads me to the conclusion that it has something to do with their handling of caching. For a bit more background both of my front pages are basic pages with the source set, so they'll forward if pulled up on the wrong domain. Digging into the new "/domain/domain_source/src/HttpKernel/DomainSourceRouteProvider.php" I notice that the 'cid' does not distinguish between domains, which leads to the exact same cache ID for both of my sites on the front page:
route:[language]=en:[query_parameters]=:/

I went ahead and added the domain to the cache ID and tested my issue and everything appears to be working correctly for me. There may be a better way to go about this, but I think it at least helps pinpoint where I'm having an issue. See my attached patch.

mably’s picture

Hi @protitude, thanks a lot for your investigation!

Not sure that code has been changed between beta 6 and 7.

I'll have a look a it.

EDIT: The related code has possibly changed between beta6 and 7. Investigating.

mably’s picture

Priority: Normal » Major
Status: Postponed (maintainer needs more info) » Needs work
mably’s picture

Priority: Major » Normal
Status: Needs work » Postponed (maintainer needs more info)

@protitude wondering how the routes can be varying per host? An idea?

Locally I have two different $cid for my 2 domains home pages:

route:[language]=en:[query_parameters]=:/node/1

And

route:[language]=fr:[query_parameters]=:/node/12

Are you using other modules to manage your home pages?

protitude’s picture

Thanks for the quick response @mably!

That's interesting. I'm using the domain_config module and setting this through Basic Site Settings:

screenshot of basic site settings
Screenshot of basic site settings

My 2 domains are as follow with my included patch:
route:[language]=en:[query_parameters]=:/:[domain]=oit.ddev.site
and
route:[language]=en:[query_parameters]=:/:[domain]=data.ddev.site

The domain modules I currently have enabled are:

  • domain
  • domain_access
  • domain_alias
  • domain_config
  • domain_config_ui
  • domain_source
  • domain_theme_switch

I think domain_theme_switch is the only one that's not included in the core domain module. I hope that's helpful.

mably’s picture

@protitude can you give us the cached routes for those 2 cids?

protitude’s picture

Here's a dump of the $cached_value for each domain, let me know if I'm misunderstanding what you need.

data site:

Array
(
    [path] => /node/31531
    [query] => Array
        (
        )

    [routes] => Symfony\Component\Routing\RouteCollection Object
        (
            [routes:Symfony\Component\Routing\RouteCollection:private] => Array
                (
                    [entity.node.canonical] => Symfony\Component\Routing\Route Object
                        (
                            [path:Symfony\Component\Routing\Route:private] => /node/{node}
                            [host:Symfony\Component\Routing\Route:private] => 
                            [schemes:Symfony\Component\Routing\Route:private] => Array
                                (
                                )

                            [methods:Symfony\Component\Routing\Route:private] => Array
                                (
                                    [0] => GET
                                    [1] => POST
                                )

                            [defaults:Symfony\Component\Routing\Route:private] => Array
                                (
                                    [_controller] => \Drupal\node\Controller\NodeViewController::view
                                    [_title_callback] => \Drupal\node\Controller\NodeViewController::title
                                )

                            [requirements:Symfony\Component\Routing\Route:private] => Array
                                (
                                    [node] => \d+
                                    [_entity_access] => node.view
                                )

                            [options:Symfony\Component\Routing\Route:private] => Array
                                (
                                    [compiler_class] => Drupal\Core\Routing\RouteCompiler
                                    [parameters] => Array
                                        (
                                            [node] => Array
                                                (
                                                    [type] => entity:node
                                                    [converter] => paramconverter.entity
                                                )

                                        )

                                    [_access_checks] => Array
                                        (
                                            [0] => access_check.entity
                                            [1] => access_check.domain
                                        )

                                    [utf8] => 1
                                )

                            [condition:Symfony\Component\Routing\Route:private] => 
                            [compiled:Symfony\Component\Routing\Route:private] => Drupal\Core\Routing\CompiledRoute Object
                                (
                                    [variables:Symfony\Component\Routing\CompiledRoute:private] => Array
                                        (
                                            [0] => node
                                        )

                                    [tokens:Symfony\Component\Routing\CompiledRoute:private] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [0] => variable
                                                    [1] => /
                                                    [2] => \d+
                                                    [3] => node
                                                    [4] => 1
                                                )

                                            [1] => Array
                                                (
                                                    [0] => text
                                                    [1] => /node
                                                )

                                        )

                                    [staticPrefix:Symfony\Component\Routing\CompiledRoute:private] => 
                                    [regex:Symfony\Component\Routing\CompiledRoute:private] => {^/node/(?P<node>\d+)$}sDu
                                    [pathVariables:Symfony\Component\Routing\CompiledRoute:private] => Array
                                        (
                                            [0] => node
                                        )

                                    [hostVariables:Symfony\Component\Routing\CompiledRoute:private] => Array
                                        (
                                        )

                                    [hostRegex:Symfony\Component\Routing\CompiledRoute:private] => 
                                    [hostTokens:Symfony\Component\Routing\CompiledRoute:private] => Array
                                        (
                                        )

                                    [fit:protected] => 2
                                    [patternOutline:protected] => /node/%
                                    [numParts:protected] => 2
                                )

                        )

                )

            [aliases:Symfony\Component\Routing\RouteCollection:private] => Array
                (
                )

            [resources:Symfony\Component\Routing\RouteCollection:private] => Array
                (
                )

            [priorities:Symfony\Component\Routing\RouteCollection:private] => Array
                (
                )

        )

)

OIT site:

Array
(
    [path] => /node/32161
    [query] => Array
        (
        )

    [routes] => Symfony\Component\Routing\RouteCollection Object
        (
            [routes:Symfony\Component\Routing\RouteCollection:private] => Array
                (
                    [entity.node.canonical] => Symfony\Component\Routing\Route Object
                        (
                            [path:Symfony\Component\Routing\Route:private] => /node/{node}
                            [host:Symfony\Component\Routing\Route:private] => 
                            [schemes:Symfony\Component\Routing\Route:private] => Array
                                (
                                )

                            [methods:Symfony\Component\Routing\Route:private] => Array
                                (
                                    [0] => GET
                                    [1] => POST
                                )

                            [defaults:Symfony\Component\Routing\Route:private] => Array
                                (
                                    [_controller] => \Drupal\node\Controller\NodeViewController::view
                                    [_title_callback] => \Drupal\node\Controller\NodeViewController::title
                                )

                            [requirements:Symfony\Component\Routing\Route:private] => Array
                                (
                                    [node] => \d+
                                    [_entity_access] => node.view
                                )

                            [options:Symfony\Component\Routing\Route:private] => Array
                                (
                                    [compiler_class] => Drupal\Core\Routing\RouteCompiler
                                    [parameters] => Array
                                        (
                                            [node] => Array
                                                (
                                                    [type] => entity:node
                                                    [converter] => paramconverter.entity
                                                )

                                        )

                                    [_access_checks] => Array
                                        (
                                            [0] => access_check.entity
                                            [1] => access_check.domain
                                        )

                                    [utf8] => 1
                                )

                            [condition:Symfony\Component\Routing\Route:private] => 
                            [compiled:Symfony\Component\Routing\Route:private] => Drupal\Core\Routing\CompiledRoute Object
                                (
                                    [variables:Symfony\Component\Routing\CompiledRoute:private] => Array
                                        (
                                            [0] => node
                                        )

                                    [tokens:Symfony\Component\Routing\CompiledRoute:private] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [0] => variable
                                                    [1] => /
                                                    [2] => \d+
                                                    [3] => node
                                                    [4] => 1
                                                )

                                            [1] => Array
                                                (
                                                    [0] => text
                                                    [1] => /node
                                                )

                                        )

                                    [staticPrefix:Symfony\Component\Routing\CompiledRoute:private] => 
                                    [regex:Symfony\Component\Routing\CompiledRoute:private] => {^/node/(?P<node>\d+)$}sDu
                                    [pathVariables:Symfony\Component\Routing\CompiledRoute:private] => Array
                                        (
                                            [0] => node
                                        )

                                    [hostVariables:Symfony\Component\Routing\CompiledRoute:private] => Array
                                        (
                                        )

                                    [hostRegex:Symfony\Component\Routing\CompiledRoute:private] => 
                                    [hostTokens:Symfony\Component\Routing\CompiledRoute:private] => Array
                                        (
                                        )

                                    [fit:protected] => 2
                                    [patternOutline:protected] => /node/%
                                    [numParts:protected] => 2
                                )

                        )

                )

            [aliases:Symfony\Component\Routing\RouteCollection:private] => Array
                (
                )

            [resources:Symfony\Component\Routing\RouteCollection:private] => Array
                (
                )

            [priorities:Symfony\Component\Routing\RouteCollection:private] => Array
                (
                )

        )

)

mably’s picture

Status: Postponed (maintainer needs more info) » Needs review
mably’s picture

@protitude could you give a try to this issue's MR please?

mably’s picture

protitude’s picture

I took a patch of your changes and everything worked as expected on our test environment. Thanks so much for looking into this so quickly, I'll deploy the patched version of the module tomorrow to our live site.

mably’s picture

@protitude thanks for testing.

If it fixes the problem on your live site, I'll merge it.

freezernick’s picture

+1 RTBC
We encountered this issue too on a multidomain installation. This patch resolved the error for our install

protitude’s picture

@mably, I just deployed to our live site and everything appears to be working as expected. This fixed it for me. Thanks again for the help.

  • mably committed ce0db498 on 2.0.x
    Issue #3555807 by protitude, mably: Only one front page for sites...

  • mably committed e2663b70 on 3.x
    Issue #3555807 by protitude, mably: Only one front page for sites...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mably’s picture

Merged.

Thanks a lot @protitude for helping fix this nasty bug!

junaidpv’s picture

Thank you! We were having this exact issue. I applied the change merged in the 2.0.x branch and it helped to fix the issue.

mably’s picture

Thanks @junaidpv for your feedback.

I'll publish a beta8 release in the coming hours.

Status: Fixed » Closed (fixed)

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