Programmatically publishing and unpublishing nodes: anonymous access We have several nodes that serve as open job postings which need to "open" and "close" on specific dates. 
In order to accomplish this, we publish and unpublish them accordingly.

We have a query (based on publish unpublished node programmatically) that successfully updates both the node table and the node_revision table:

$result = db_query('update node n
JOIN field_data_field_jobs_date d ON d.entity_id = n.nid and d.revision_id = n.vid
JOIN node_revision r ON n.nid = r.nid and n.vid = r.vid
# Update the node_revision table
SET r.status = IF(
    ( 
    CURDATE() &gt;= d.field_jobs_date_value 
    AND 
    CURDATE() &lt;= d.field_jobs_date_value2
    ),1,0
),
# Update the node table
n.status = IF(
    ( 
    CURDATE() &gt;= d.field_jobs_date_value 
    AND 
    CURDATE() &lt;= d.field_jobs_date_value2
    ),1,0
)
# Only update our custom content type
WHERE n.type = \'job_posting\'');


This successfully updates the node status and node revision status in the database.

However, once a node has been published through this method, anonymous users still cannot see it (and are presented access denied if given a direct link to the node). 

We have to manually edit each node and hit the save button for the published status to "take." This leads me to believe that we are omitting some sort of call to node access or something similar that updates the permissions on the node appropriately.

Any ideas besides the status field that may be preventing anonymous users from seeing programatically published nodes?
Most probably caching. Directly changing something in the database is, though the fastest, not really the safest / most reliable way of doing things in Drupal.

I'd suggest to use enity_query (or in this case even direct database access) to retrieve node ids of nodes you want to update and then use 'correct' drupal way of doing things -> load all the nodes, individually change their publish status and save them.

Something along these lines...

$nodes = node_load_multiple($nids);
foreach ($nodes as $node) {
  // set status property to 1
  $node-&gt;status = 1;
  // re-save the node
  node_save($node);
}