Node Access Rebuild never finishes (infinite loop)

Created on 30 September 2008, almost 16 years ago
Updated 15 September 2023, 12 months ago

Problem/Motivation

Small bug in the core "node" module's node.module

Current code:

function _node_access_rebuild_batch_operation(&$context) {
....
  while ($row = db_fetch_array($result)) {
    $loaded_node = node_load($row['nid'], NULL, TRUE);
    // To preserve database integrity, only aquire grants if the node
    // loads successfully.
    if (!empty($loaded_node)) {
      node_access_acquire_grants($loaded_node);
    }
    $context['sandbox']['progress']++;
    $context['sandbox']['current_node'] = $loaded_node->nid;
  }
...
}

The last line in this while loop should read: $context['sandbox']['current_node'] = $row['nid'];

As if the loaded is empty, $loaded_node->nid will be empty too causing an infinite loop in the batch operation, as it takes an empty value for $context['sandbox']['current_node'] as meaning it has not yet started the rebuild and starts all over again.

Steps to reproduce

Not sure

Proposed resolution

Based on patch #42. Loop through the $nids vs loaded $nodes and check if $nid is in the $node array first.

Remaining tasks

Maybe test = @catch mentioned in #46 this may not be possible

User interface changes

NA

API changes

NA

Data model changes

NA

Release notes snippet

NA

🐛 Bug report
Status

Fixed

Version

10.1

Component
Node system 

Last updated 1 minute ago

No maintainer
Created by

🇮🇪Ireland PaulMagrath

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.

Production build 0.71.5 2024