- Issue created by @medusa43
- 🇨🇭Switzerland redzeuf Geneva
I have exactly the same error message when trying to access a add content page in the admin with a user having specific role (for admin it works well).
Here is a patch. It looks like the is_null logic is_numeric are the opposite that needed.
I also take care of the non object that is mentioned in issue https://www.drupal.org/project/domain/issues/2936697 → - 🇨🇭Switzerland redzeuf Geneva
oups here is the applicable patch for pervious comment.
- First commit to issue fork.
- Merge request !134Issue #3488024 Fix for getDomainId on NULL + added TODO about discrepancy between code and docs. → (Merged) created by andreasderijcke
- 🇧🇪Belgium andreasderijcke Antwerpen / Gent
Different patch as MR, because I think the base check can be simplified.
In addition, the is_numeric check should not be necessary according to the return type of getDomainId(), so either the check is obsolete, or the function doc is incomplete.
As I don't have the correct answer, have flagged it as a todo. - 🇨🇦Canada danrod Ottawa
As mentioned in the file
domain_access/domain_acccess.module
lines 416-421, this needs to be reviewed:// @todo According to \Drupal\domain\DomainInterface::getDomainId, only // integers are returned. Either this check is obsolete, or the function // documentation is incomplete. if (!is_numeric($active_domain->getDomainId())) { return AccessResult::neutral(); }
As far as I know this method always returns an integer, not NULL or 0, but I think we can merge this MR for now.
- 🇫🇷France mably
Not sure to understand what the original problem is exactly?
Could someone mind explaining?
-
danrod →
committed d564754c on 2.0.x authored by
andreasderijcke →
Issue #3488024 Fix for getDomainId on NULL + added TODO about...
-
danrod →
committed d564754c on 2.0.x authored by
andreasderijcke →
- 🇨🇦Canada danrod Ottawa
Merged to the 2.0.x branch, thanks everyone for the input, if anyone is still having any problems with this, I can re-open the issue.
- 🇫🇷France mably
@danrod could you explain what the original problem was exactly?
Not sure to understand why the
is_null
test was not working. - 🇨🇦Canada danrod Ottawa
@mably some users were reporting that the variable
$active_domain
being NULL in the filedomain_access/domain_access.module
line 419:$id = $active_domain->getDomainId();
Not sure why exactly, and I tried to reproduce it and I couldn't, so a different condition was proposed to check if
$active_domain
is a valid object and not empty: https://git.drupalcode.org/project/domain/-/merge_requests/134/diffsAlso, an extra condition was added:
/ @todo According to \Drupal\domain\DomainInterface::getDomainId, only // integers are returned. Either this check is obsolete, or the function // documentation is incomplete. if (!is_numeric($active_domain->getDomainId())) { return AccessResult::neutral(); }
In theory,
$active_domain->getDomainId()
should always return an integer. - 🇫🇷France mably
Don't see how
$active_domain
could beNULL
on line 419, probably a different codebase...Anyway, the change seems ok, but it will probably not fix the original problem.
- 🇨🇦Canada danrod Ottawa
Alright, thanks @mably , I'll let you know in advance when I try to merge an issue to the 2.0.x branch, the change seems to have fixed the issue for some users, let's see.
- 🇨🇦Canada danrod Ottawa
@mable I'll move it to "Fixed" for now (since it's already committed to the 2.0.x branch), we can re-open it if the issue re-appears again.
Automatically closed - issue fixed for 2 weeks with no activity.