When we go to any node and go to grants tab node/{nid}/grants tp enable permission to particular user doesn't work

Steps to reproduce

1. Go to node/{nid}/grants

2. Enter username to get the user then click search button it gives an error

nodeaccess by user

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42704]: Undefined object: 7 ERROR: type "unsigned" does not exist LINE 3: ...r__roles r ON (na.gid = CAST(r.roles_target_id as unsigned)) ^: SELECT count(*) FROM {node_access} na LEFT JOIN {user__roles} r ON (na.gid = CAST(r.roles_target_id as unsigned)) WHERE na.nid = :nid AND na.realm = :realm AND r.entity_id = :uid AND :grant_type = :one LIMIT 1 OFFSET 0; Array ( [:nid] => 7 [:realm] => nodeaccess_rid [:uid] => 757 [:grant_type] => grant_view [:one] => 1 ) in Drupal\nodeaccess\Form\GrantsForm->buildForm() (line 133 of {web_root}/modules/contrib/nodeaccess/src/Form/GrantsForm.php).

CommentFileSizeAuthor
#2 3185156-2.patch893 bytesjungle
nodeaccess.JPG16.88 KBsamhaldia

Comments

samhaldia created an issue. See original summary.

jungle’s picture

Status: Active » Needs review
StatusFileSize
new893 bytes

Maybe the following are related

-      $query->fields('ufd', ['name']);
+      $query->fields('ufd', ['name', 'uid']);
       $query->condition('n.nid', $nid, '=');
       $query->condition('n.realm', 'nodeaccess_uid', '=');
       $query->orderBy('ufd.name', 'ASC');
       $results = $query->execute();
-      while ($acounts = $results->fetchAssoc()) {
+      while ($account = $results->fetchObject()) {
         $form_values['uid'][$account->uid] = [
jungle’s picture

I encountered the error above too, but with the patch above, the error was gone.

jungle’s picture

Status: Needs review » Needs work

Setting back to NW to get the root cause.

alison’s picture

Is this issue specific to Drupal 9, or also Drupal 8?

jungle’s picture

@alisonjo315

Both D8 and D9. and I think this is a duplicate of #3061378.

Thanks.

jungle’s picture

Priority: Major » Normal
Status: Needs work » Postponed (maintainer needs more info)

With the latest code: commit ID 355f010, I could not reproduce this bug. Maybe this was fixed.

Let's postpone it and close it in two or four weeks if no further progress here.

jungle’s picture

Version: 8.x-1.0 » 2.0.x-dev
Status: Postponed (maintainer needs more info) » Closed (works as designed)
Parent issue: » #3317693: [Meta] 2.0.x branch: Working toward a stable release

The bug was gone in the new 2.0.x branch I think.