Using Drupal 7 version 7.39 when I save a node the users that have access to this node disappear from the grant tab.
I checked and the access is removed from node_access and nodeaccess tables.
I realize that the nodeaccess function nodeaccess_delete_user_reference it's called in the process. Inside this function user_load_multiple is called with a null value as parameter. In this case, user_load_multiple is returning all the users.
I did a small patch to overcome this. The path is also fixing the original problem of losing the data from the access tables.

Comments

dublutz created an issue. See original summary.

joelpittet’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Assigned: dublutz » Unassigned
Status: Patch (to be ported) » Needs review
Issue tags: -lost grant access node save

Patch to be ported is when it needs a backport or forward port from 7 to 6 for example.

carsonw’s picture

Status: Needs review » Reviewed & tested by the community

Confirmed the same issue on another website that reported this bug to me. Reviewed, applied, and tested successfully.

april26’s picture

I added the patch, but when the node is edited and saved, all the grant access names disappear. If anyone has a solution for this (or know of another module that allows view access by username), please let me know!

Petrica’s picture

StatusFileSize
new1.22 KB

For Drupal 7.41 this patch throws the following warnings:

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 388 of includes/entity.inc).

I am attaching a patch to fix those.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: nodeaccess-730664-2.patch, failed testing.

The last submitted patch, 5: nodeaccess-730664-2.patch, failed testing.

joelpittet’s picture

@Pertrica the testbot is failing on the short array syntax because Drupal 7 supports > PHP 5.2

Petrica’s picture

StatusFileSize
new1.22 KB

Added new patch for PHP 5.2 compatibility

joelpittet’s picture

Status: Needs work » Needs review
d.fisher’s picture

Status: Needs review » Postponed (maintainer needs more info)

Drupal 7 security support has ended as of 5 January 2025.

We are doing some housekeeping on the nodeaccess issue queue and moving all Drupal 7 issues to "postponed (maintainer needs more info)". See https://www.drupal.org/project/nodeaccess/issues/3516593.

If this issue persists on the latest dev branch of nodeaccess (2.0.x-dev) then please feel free to comment and we will change the version against this issue. If we do not hear any feedback within 2 weeks (9th October 2025) we will go ahead and close this issue as outdated.

Thank you.

d.fisher’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

As per the above, as there has been no response we will now close this issue as outdated.

If this issue persists on the latest dev branch of nodeaccess (2.0.x-dev) then please feel free to update the version on this issue and reopen it.

Thank you.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.