Hi,

Using 7x-1.4 and view_unpublished 7.x-1.2 with view unpublished content type X in perms, unpublishing a node or calling node_access_acquire_grants on an unpublished node gives no entries in the node_access table.

This happens w/o regard to the weight of either nodeaccess or view_unpublished.

If i update nodeaccess to 7.x-1.x-dev, i get the appropriate view entries in node_access, but for other content types with special grants in nodeaccess (eg, role N has nodeaccess_view), the only entry in nodeaccess after a node_save is nodeaccess_author with all three grant columns 0. Then node_access has no entries for that node, ie no access except for those with bypass access control.

I don't know the cause, but i wrote a quick solution:

Note nodeaccess has weight 0.

function mymodule_nafix_install()
{
        db_update('system')
                ->fields(array('weight' => -1))
                ->condition('name', 'mymodule_nafix', '=')
                ->execute();
}

function mymodule_nafix_node_access_records_alter(&$grants, $node)
{
        if(!empty($grants))
        {
                foreach($grants as $key=>$grant)
                {
                        if($grant['realm'] == 'nodeaccess_author'
                                && $grant['grant_view'] == 0
                                && $grant['grant_update'] == 0
                                && $grant['grant_delete'] == 0)
                        {
                                unset($grants[$key]);
                                $q = db_query("delete from nodeaccess where realm='nodeaccess_author' and nid=:d and grant_view=0 and grant_update=0 and grant_delete=0", array(':d' => $node->nid));
                        }
                }
        }
}

It appears to fix the problem, but i don't know any side effects yet, and i'd prefer to fix the underlying cause of the nodeaccess_author, 0, 0, 0 entry.

Cheers.

Comments

d.fisher’s picture

Status: Active » 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.