Move the gtag_domain condition plugin to a submodule

Created on 18 July 2022, over 2 years ago
Updated 24 October 2023, about 1 year ago

Problem/Motivation

The google_tag module comes with a condition plugin, that uses a a service domain.negotiator from the domain module.

However, the domain module doesn't need to be a dependency of the google_tag module.

That can lead on an un-handled dependency under certain circumstances:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "domain.negotiator". in Drupal\Component\DependencyInjection\Container->get() (line 156 of /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php).

I found that exception when working with a custom module, which has a "domain" entity type and context.

We could discuss if the "domain" entity id is correct, even if the domain module is not installed, but even with that in mind, would be more correct to have any code depending on the "domain" module, in a submodule depending on "domain".

Steps to reproduce

Proposed resolution

Recommend to sites using gtag_domain to convert to using the domain condition plugin from Domain module.

Remaining tasks

- Patch
- Review
- Test

User interface changes

- None

API changes

- There's a new submodule called google_tag_domain with the gtag_domain condition plugin inside.

Data model changes

- None

πŸ“Œ Task
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain akalam

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany lucastockmann

    I have the exact same problem where the Domain module is not enabled and this breaks the Condition Plugin System, so that it is no longer possible to edit fields using the plugin select list plugin selector.

    @solotandem: What issues do you mean by?

    My preference would be to see core commit a simple change (see other issues) which would make this problem go away.

  • πŸ‡©πŸ‡ͺGermany SteffenR Germany

    From my understanding, we could also use the calculateDependencies in the dependency plugin.

    public function calculateDependencies() {
      return parent::calculateDependencies() + [
          'module' => ['domain'],
        ];
    }
    

    Unfortunately this was not working on my existing site.

  • πŸ‡³πŸ‡ΏNew Zealand xurizaemon Ōtepoti, Aotearoa 🏝

    @solotandem it would be easier to understand your proposed approach if "see other issues" linked to the mentioned "simple change" that you hope to see core commit. Without that context it's not clear what you hope might address the challenge.

    For Acquia sites using that Domain condition plugin in 8.x-1.x series and not available in 2.0.x, the requirement to update to Google Tag 2.0.x (acquia/acquia_cms 2.2.0 requires drupal/google_tag (^2.0)) may be a sticking point.

    If your comment pointed to the relevant issue then folks hitting this issue would be better able to consider the approach you're proposing.

  • πŸ‡³πŸ‡ΏNew Zealand xurizaemon Ōtepoti, Aotearoa 🏝

    Is the Google Tag Domain module redundant by way of Domain module's domain plugin?

    If so, the configuration change to switch may look like this:

     conditions:
    -  gtag_domain:
    -    id: gtag_domain
    +  domain:
    +    id: domain
    +    negate: false
         context_mapping:
    -      'entity:domain': '@domain.current_domain_context:domain'
    -    domain_toggle: 'include listed'
    -    domain_list:
    +      domain: '@domain.current_domain_context:domain'
    +    domains:
           yourdomain: yourdomain
    
  • πŸ‡³πŸ‡ΏNew Zealand patrickharris

    Yes xurizaemon, the Domain module's own plugin seems to work in an identical fashion.

  • Status changed to Closed: won't fix about 1 year ago
  • πŸ‡³πŸ‡ΏNew Zealand xurizaemon Ōtepoti, Aotearoa 🏝

    Based on my and Patrick assessment, it seems the gtag_domain plugin can be dropped, replaced with the domain condition plugin from Domain module.

    - https://git.drupalcode.org/project/domain/-/blob/8.x-1.x/domain/src/Plug...

    Updated ID. Proactively closing "won't fix" - anyone is welcome to pick this up and run with it in the direction of their choice :)

Production build 0.71.5 2024