Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Chi created an issue. See original summary.

acrosman’s picture

Try rebuilding the permissions. If that fails see #2719605: AJAX error when rebuilding permissions

roy_k’s picture

This is what I see in the message and it mutiple:

Notice: Undefined index: anonymous in content_access_get_role_gid() (line 694 of modules/content_access/content_access.module).

content_access_get_role_gid('anonymous') (Line: 53)

content_access_node_grants(Object, 'view')

call_user_func_array('content_access_node_grants', Array) (Line: 402)

Drupal\Core\Extension\ModuleHandler->invokeAll('node_grants', Array) (Line: 954)

node_access_grants('view', Object) (Line: 101)

Drupal\node\NodeGrantDatabaseStorage->access(Object, 'view', Object) (Line: 107)

Drupal\node\NodeAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 93)

Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 68)

Drupal\node\NodeAccessControlHandler->access(Object, 'view', Object, 1) (Line: 593)

Drupal\Core\Entity\ContentEntityBase->access('view', Object, 1) (Line: 182)

Drupal\node\Entity\Node->access('view', Object, 1) (Line: 61)

Drupal\Core\Entity\EntityAccessCheck->access(Object, Object, Object)

call_user_func_array(Array, Array) (Line: 163)

Drupal\Core\Access\AccessManager->performCheck('access_check.entity', Object) (Line: 139)

Drupal\Core\Access\AccessManager->check(Object, Object, Object, 1) (Line: 112)

Drupal\Core\Access\AccessManager->checkRequest(Object, Object, 1) (Line: 102)

Drupal\Core\Routing\AccessAwareRouter->checkAccess(Object) (Line: 87)

Drupal\Core\Routing\AccessAwareRouter->matchRequest(Object) (Line: 154)

Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest(Object, 'kernel.request', Object) (Line: 111)

Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.request', Object) (Line: 120)

Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)

Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)

Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)

Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 207)

Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 121)

Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 75)

Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)

Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)

Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)

Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)

Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I tried to rebuild the permissions and it didn`t do anything.
I will try to dig in deeper (and find a solution to it on the way) next week (unless someone else found a solution for it before I do).

OlivierG’s picture

I did a patch for this. I don't know if it's correct but it's better without error...

smfmoreno’s picture

thank you, the patch #4 works for me!

dsdeiz’s picture

dsdeiz’s picture

Status: Active » Needs review
LpSolit’s picture

Priority: Major » Normal
Status: Needs review » Needs work

This patch won't work as it now always returns NULL. (and it has a double ;; )

samalander’s picture

#4 patch worked for me as well. You just need to apply it from the drupal root rather than in the module's folder.

acrollet’s picture

The patches are addressing a symptom rather than the root issue. The root issue is that the role GIDs are not properly populated. I worked around the issue on a site by re-running the code in content_access_install() - not sure why/how the anonymous GID was no longer saved in the config object though.

samalander’s picture

Thanks @acrollet (#10). I followed your advice and ran:

drush php:eval "require_once('modules/contrib/content_access/content_access.install');content_access_install();"

after reverting to the existing code and all the messages stopped.

superlolo95’s picture

+ 1 for the #10 and #11

jeremyH1024’s picture

Having this issue.

Tried #11 - The drush command 'php:eval require_once('modules/contrib/content_access/content_access.install');content_access_install();' could not be found. Run `drush cache-clear drush` to clear the commandfile [error]
cache if you have installed new extensions.

Tried clearing cache but same issue.

This is annoying. My customers are complaining.

Sardis’s picture

#10 saved the day! Much appreciated!

nicolas-mosch’s picture

#10 How exactly do I re-run the code in content_access_install()? I tried uninstalling the module and installing it again in the Drupal ui with no success.

Sardis’s picture

@nicolas-mosch if you have drush installed you could use drush php-eval or drush core-cli.

Or you could enable devel module. It will have a route devel/php. There you'll see tex tarea for pasting the code from content_access.install

Farnoosh’s picture

#4 worked for me.

brooke_heaton’s picture

#4 worked for me.

mikhailkrainiuk’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
478 bytes

Hello!

#10 patch has syntax error - $roles_gid instead of $roles_gids.
It shows the message for me:

Notice: Undefined variable: roles_gid in content_access_get_role_gid() (line 689 of modules/contrib/content_access/content_access.module).

Added the fixed patch. Other logic works for me fine.

LpSolit’s picture

Status: Reviewed & tested by the community » Needs work

As I said in comment 8, you now always return NULL (+ a typo). This is not what we want, right? Comment 10 also disagrees with this fix.

mikhailkrainiuk’s picture

Ah, understood. Sorry.
Hm... Why we can't use ID's from the roles? (machine names)

brooke_heaton’s picture

I attempted patch #19 and it removed the Notice however it resulted in a fatal error upon saving content:

"General error: 1366 Incorrect integer value: '' for column 'gid' at row 1: INSERT INTO {node_access}"

gagelafleur’s picture

This is my first patch, so if I've done anything incorrectly please bear with me. I believe patch #19 just needed a return statement added to it.

gagelafleur’s picture

Status: Needs work » Needs review
gagelafleur’s picture

Trying this again. Still not sure if I'm doing something wrong, but I read into it more and created this version of the patch automatically via git diff.

gisle’s picture

Status: Needs review » Closed (cannot reproduce)

I believe this is not a bug, and that the patch is not needed. The solution is to make sure the module is properly installed - see comment #10.

I am unable to reproduce the behaviour reported in the issue summary. No notice appear on each page request when browsing as an anonymous user.

The notice reproduced in the issue summary says that the index 'anonymous' is undefined. The array in question is $roles_gids, and when I examine it on a newly installed Drupal 8.9.5 site, it has this contents:

Array(
    [anonymous] => 1
    [authenticated] => 2
    [administrator] => 3
)

I.e. 'anonymous' it is not undefined if the module has been correctly installed.