view_unpublished and nodeaccess_author issue?

Created on 14 July 2015, about 10 years ago
Updated 25 September 2025, 11 days ago

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.

πŸ› Bug report
Status

Postponed: needs info

Version

1.4

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States davery

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024