View not show subdomain nodes for anonymous user

Created on 6 June 2023, over 1 year ago
Updated 2 June 2024, 8 months ago

Versions

Drupal -> 9.4.8
Php -> 8.0.20
Mariadb -> 8.0.33

Domain module version

8.x-1.0-beta6

Expected Behavior

[What did you try to do? What URL did you use to do it?]
I have several domains, from the default I have a view that shows all the nodes, but it does not show those of the subdomains, these nodes do not have send to all affiliates or the default domain marked, only has marked subdomain option.

Example:
default_domain:
subdomain_1:
subdomain_2:
subdomain_3:

I access the view from the default_domain page with anonymous user,
and it shows the nodes that are assigned the domain default_domain, but I need it to show the nodes that are assigned subdomain_1, subdomain_2 or subdomain_3.

I don't know if I'm doing something that isn't allowed initially but I need this.
I have seen that in domain_access.module it does this:

if ($op == 'view') {
    if ($node->isPublished()) {
      // Explicit restatement of the condition, for clarity.
      $allowed = FALSE;
    }
    elseif ($account->hasPermission('view unpublished domain content') && $manager->checkEntityAccess($node, $account)) {
      $allowed = TRUE;
    }
  }

I have modified it like this and it works as I need, what impact would it have?:

if ($op == 'view') {
    if ($node->isPublished()) {
      // Explicit restatement of the condition, for clarity.
      $allowed = TRUE;
    }
    elseif ($account->hasPermission('view unpublished domain content') && $manager->checkEntityAccess($node, $account)) {
      $allowed = TRUE;
    }
  }

I think that if a node is published it should always be viewable by an anonymous user, if you prefer I can add a specific permission for this case and add it to the condition of if a content is published and has that permission, set the allow to true

something like that:

if ($op == 'view') {
    if ($node->isPublished()) {
      // Explicit restatement of the condition, for clarity.
      $allowed = FALSE;
    }
    elseif ($account->hasPermission('view published domain content') && $node->isPublished()) {
      $allowed = TRUE;
    }
    elseif ($account->hasPermission('view unpublished domain content') && $manager->checkEntityAccess($node, $account)) {
      $allowed = TRUE;
    }
  }

Thanks in advance, I hope I have explained myself.

💬 Support request
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

🇪🇸Spain Carlos Romero

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

Merge Requests

Comments & Activities

  • Issue created by @Carlos Romero
  • Status changed to Closed: works as designed 8 months ago
  • 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin

    I access the view from the default_domain page with anonymous user,
    and it shows the nodes that are assigned the domain default_domain, but I need it to show the nodes that are assigned subdomain_1, subdomain_2 or subdomain_3

    From my understanding you try to achieve something which in its result is rather "the opposite" of what Domain module wants to provide here. Domain module cannot operate in opposite logic for the same form. Domain simply does show content for selected nodes. If you want to show all nodes regardless of the domains they are assigned to you need a simply view ignoring the domain filter. If this is not working because of the circumstance that you do not call the nodes list in admin area but on a certain domain as not logged in user, well you fall into the case of Domain's supposed logic since the call from this domain restricts content to be shown from this domain only of course. To circumvent this for edge cases I usually recommend to serve one domain as "management domain only" which is always selected per default on each node. This way you have a domain which will show all content. No hacks or patches needed.

Production build 0.71.5 2024