Once I've set up the smartqueue for my group content type and submit the form, it creates smartqueues for each existing group. But, when I create a new group, it doesn't seem as if the queue for the new group is created. If I resubmit the smartqueue form, the new group's queue is created.

Am I missing something, or is this the desired behaviour?

In my case, I'd like this to be automatic - so if it's not a behaviour catered for with this module, I think I will use something like workflow-ng to force the creation of the subqueue. Then, when a new group is created, the subqueue is also created.

Let me know if you think there's a better way to do it, or if I'm missing something :-)

Thanks.

Comments

ezra-g’s picture

It *should* create a new queue for all eligible nodes. It checks new/updated nodes with smartqueue_og_eligible_group_type($node->type).

foxtrotcharlie’s picture

Ja, I thought so. It does create it because it tells me in the notice message. But, it doesn't appear in the smartqueue list.

When looking in the database though it's referencing a non-existent nodequeue (qid=0). So I deleted all nodequeues and subqueues, and manually deleted a couple of orphaned rows in the nodequeue_subqueue table, recreated the smartqueue for my groups, which created the subqueues for all existing groups. But, when I created a new group, although it tells me it's created a new node queue, it doesn't appear in the list of all the subqueues.

When I check the database the new subqueue is there, but the qid=0;

I checked the code, and it looks like the correct qid is returned from the function smartqueue_og_get_qid(), and the problem manifests in the function nodequeue_add_subqueue

/**
 * Add a new subqueue to a queue.
 *
 * @param $qid
 *   The queue id. This should not be the full queue object.
 * @param $reference
 *   A reference that uniquely identifies this subqueue. If NULL it will
 *   be assigned to the sqid.
 */
function nodequeue_add_subqueue(&$queue, $title, $reference = NULL) {
  $sqid = db_next_id('{nodequeue_subqueue}_sqid');
  if (empty($reference)) {
    $reference = $sqid;
  }

  $subqueue = new stdClass();
  $subqueue->sqid = $sqid;
  $subqueue->reference = $reference;
  $subqueue->qid = $queue->qid;
  $subqueue->title = $title;

  db_query("INSERT INTO {nodequeue_subqueue} (qid, sqid, reference, title) VALUES (%d, %d, '%s', '%s')", $queue->qid, $sqid, $reference, $title);

  return $subqueue;
}

In the line where it assigns the subqueue qid it's expecting the $queue parameter to be an object, where it's actually an integer that's obtained from the function smartqueue_og_get_qid().

If I change the function smartqueue_og_nodeapi at line 324 from:

        if ($subqueue = !smartqueue_og_load_group_subqueue($node->nid)) {
          nodequeue_add_subqueue(smartqueue_og_get_qid(), "$node->title's Node Queue", $node->nid);
          drupal_set_message(t("Created a Node Queue for @title .", array('@title' => $node->title)));
        }

To:

        if ($subqueue = !smartqueue_og_load_group_subqueue($node->nid)) {
        	$queue = (object)array('qid' => smartqueue_og_get_qid());
          nodequeue_add_subqueue($queue, "$node->title's Node Queue", $node->nid);
          drupal_set_message(t("Created a Node Queue for @title .", array('@title' => $node->title)));
        }

By first creating the queue object, and passing this to the nodequeue_add_subqueue function, the new group is assigned to the correct qid. I'm not sure if this change would cause any issues anywhere else though? Does this seem like a good solution? Can you even replicate my issue?

foxtrotcharlie’s picture

Im not sure, but perhaps it's better to do the creation of the queue object as follows, instead of how I did it above:

        	$queue = new stdClass();
        	$queue->qid = smartqueue_og_get_qid();
ezra-g’s picture

Title: Is the group queue automatically generated when a new group node is created? » Group queues created with qid 0
Category: support » bug

Thanks for this report. I'll try to replicate this and see what's going on.

ezra-g’s picture

Status: Active » Fixed

I manually applied a fix for this problem. Thanks for identifying it! FYI, issues generally get addressed quicker with patches :D.

See http://drupal.org/patch/create for instructions on creating a patch.

foxtrotcharlie’s picture

lol - yes, but the first one is always so daunting ;-) And I'm on windows - I get the feeling it's slightly harder. But, that's no excuse. I promise to do it the next time, no matter what :D

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.