Drupal Version

D10

Domain module version

2.0.0-rc1

Issue summary

I was working on a legacy project where client had reported a bug of two different pages sharing content (we have domain access enabled and the contents where only assign to 1 domain, but visible on 2). this project have up to 14 domains but the problem was only on 2 of them
We found the problem was related with the domain_id var, most likely because someone copied the config of the domain 1 to create domain 2, but they only change the hostname and the id, not the domain_id

Possible solution

I think on a config import there should be a check, as there is one that checks if hostname or id are already in use

Steps to reproduce

  • Copy a domain.record configuracion
  • Change only hostname and id
  • import

Issue fork domain-3570251

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

paucala created an issue. See original summary.

mably’s picture

We could try displaying an error in the site dashboard in case of duplicated domain_id.

Could that help?

mably’s picture

Status: Active » Postponed (maintainer needs more info)
paucala’s picture

If i try to change diractly in the configuration something, but the id or hostname are alredy in use, an error displays on my console (i'm doing it with drush cim)
"Unexpected error during update for domain.record.X The hostname Y is already registred"
The same with id

But when I use the same domain_id it does'nt give any error, it should give the same

I don't know if that what you're suggesting

mably’s picture

There is nothing we can do about manual configuration editing I think. But I'm no expert there.

I was just suggesting to display a warning message on the Drupal dashboard when such duplicated domain_ids exist.

I guess we can also regenerate that id programmatically. That will require to rebuild permissions after.

paucala’s picture

So you mean that the check on the hostname or id is applied outside the domain module?

mably’s picture

Ah, you mean, you are editing the domain records using the Domain module configuration screen?

You are talking about this message here?

https://git.drupalcode.org/project/domain/-/blob/3.0.0-beta1/domain/src/...

We could add a similar check here for domain_id for sure.

Is it what you think would be the best solution to your problem?

EDIT: Actually it's using the domain_id to check for duplicate hostname... 🤔

Not really sure what to do here.

The simpler seems to display an error message on the Drupal dashboard in case of duplicate domain_id.

mably’s picture

Here is the message that is displayed on the Drupal dashboard with current MR:

Duplicate ID error message

@paucala could this be a solution to your problem?

mably’s picture

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

FYI you can easily change the value of the domain_id of your domain record by using the Config Editor of the Devel module.

Or you can simply do an export/import of the corresponding configuration file via the Configuration > Development > Configuration synchronisation menu.

mably’s picture

Looks like we can implement an event listener which listen to ConfigEvents::IMPORT_VALIDATE events to validate configuration on import.

Will have a look at it.

mably’s picture

Updated MR with a config import validator.

Here is what we get:

Config import validator

mably’s picture

Looks like the original problem is solved.

Can you confirm @paucala?

paucala’s picture

Yes @mably, I think that solves it, thank you

I assume this will also work if you are importing with drush instead of Drupal dashboard

Thank's

mably’s picture

Ok, let's merge this, thanks!

  • mably committed a1780a0d on 3.x
    fix: #3570251 domain_id allows duplicate, sharing content between domain...

  • mably committed e97d43d4 on 2.0.x
    fix: #3570251 domain_id allows duplicate, sharing content between domain...
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.

Status: Fixed » Closed (fixed)

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