I upgraded nodequeue from version 2.0-beta1 to version 2.1. After upgrading my site couldn't find the function nodequeue_nids_visible. This function is in version 2.0-beta1. It is not in version 2.1 (or even 2.0, I checked). I can find no mention to the function being removed.

Here is the function as it exists in version 2.0-beta1

function nodequeue_nids_visible($sqid = -1, $account = NULL) {
  $node_status_sql = '';
  if (!$account) {
    global $user;
    $account = $user;
  }
  $nids_visible = array();

  $query = db_select('node', 'n')
    ->fields('n', array('nid'))
    ->addTag('node_access')
    ->distinct()
    ->condition('nq.sqid', $sqid)
    ->orderBy('nq.position', 'ASC');
  $query->leftJoin('nodequeue_nodes', 'nq', 'nq.nid = n.nid');

  if (!user_access('administer nodes', $account)) {
    $query->condition(db_or()->condition('n.status', 1)->condition('n.uid', $account->uid));
  }

  // Disable i18n_select for this query.
  if (arg(0) == 'admin') {
    $query->addTag('i18n_select');
  }

  $query_restricted = $query->execute();
  foreach ($query_restricted as $result_restricted) {
    $nids_visible[$result_restricted->nid] = $result_restricted->nid;
  }
  return $nids_visible;
}

Has it moved to another module? If so where? If not, can the function be added back into the nodequeue module?

Thanks in advance.

Comments

kenrbnsn created an issue.

fizk’s picture

nodequeue_nids_visible() was removed in #1871816: Node access checking is wrong. I'm not sure why Drupal is still trying to call that function.

Can you try clearing the Drupal cache and if it issue continues, copy/paste the exact PHP error message?

kenrbnsn’s picture

I cleared the cache many times. That won't help if the function is not in the source. I looked (search in the editor & Linux grep). I will post the exact error message tomorrow when I have access to the machine where this happened.

kenrbnsn’s picture

Here is the error message I am getting (from the Apache logs)
PHP Fatal error: Call to undefined function nodequeue_nids_visible() [rest of message which refers to a custom module removed]

fizk’s picture

Can you copy/paste the exact message. I need to see what was written where you have "rest of message which refers to a custom module removed".

kenrbnsn’s picture

Here is the whole error

[Thu Aug 31 08:47:43.274454 2017] [:error] [pid 40208] [client 192.168.78.1:57615] PHP Fatal error:  Call to undefined function nodequeue_nids_visible() in /var/www/html/postaward/profiles/ruprof/modules/platform/platform.module on line 442

Here is the code from the custom module with line 442 indicated:

/**
 * Implements hook_preprocess_html().
 *
 * This checks if the homequeue_top has content and adds a CSS class. This is
 * so the height of the masthead area can be modified based on the whether the
 * queue has content. If no content, don't drop the background below the conent.
 */
function platform_preprocess_html(&$variables) {
  if ($variables['is_front']) {
    $queue = nodequeue_load_queue_by_name('homepage_top');
    $queue_count = nodequeue_nids_visible($queue->qid);   // <--- Line 442
    if (!empty($queue_count)) {
      $variables['classes_array'][] = 'has-homequeue-top';
    }
  }
}

BTW, I downloaded 7.x-2.0-beta1 and 7.x-2.0 to separate directories

When I do a
find . -type f | xargs grep -n nodequeue_nids_visible
in the beta1 directory, I get

./includes/nodequeue.admin.inc:731:  $visible = nodequeue_nids_visible($subqueue->sqid);
./nodequeue.module:2051:function nodequeue_nids_visible($sqid = -1, $account = NULL) {

When I do the same command in the 2.0 directory, the command doesn't find any lines.

The web site that's using this code hadn't been updated in quite a few years & I'm trying to bring it up to date. This missing function is a show stopper for my task, unless I revert back to the beta version.

fizk’s picture

The patch in #1871816: Node access checking is wrong replaces the call to nodequeue_nids_visible() with a call to node_access('view', $node):

-    $node->visible = isset($visible[$node->nid]) ? TRUE : FALSE;
+    $node->visible = node_access('view', $node) ? TRUE : FALSE;

Try using node_access('view', $node) instead in /var/www/html/postaward/profiles/ruprof/modules/platform/platform.module on line 442.

EDIT:

Actually, it looks like you want to use _nodequeue_dragdrop_get_nodes(). We probably need a public facing function (no underscore) so that contrib modules can reliably expect to use them.