1

All my code is here, the queues are created in backoffice, but the action in the worker call back is never processed. ! I lean the node creation in my function inalco_publications_queue_worker is seemingly not executed at all. I run many times the cron.

  $queues['inalco_publications_queue'] = array(
    'worker callback' => 'inalco_publications_queue_worker',
    // One second max runtime per cron run.
    'time' => 60,
  );

  return $queues;
}

/**
 * Implements hook_cron().
 *
 * hook_cron() is the traditional (pre-Drupal 7) hook for doing "background"
 * processing. It gets called every time the Drupal cron runs and must decide
 * what it will do.
 *
 * In this example, it does a node creation of all Inalco publications linked to REVUE
 */
function inalco_publications_cron() {

       $num_updated = db_update('node')
        ->fields(array(
          'title' => 656655,
          'status' => 1,
        ))
        ->condition('type','test_queue_api', '=')
        ->execute();


    $numeros_revue_bodies = "SELECT entity_id, body_value FROM {field_data_body} where bundle = :bundle";
    $result = db_query($numeros_revue_bodies, array(':bundle' => 'inalco_numero_revue'));

    $queue = DrupalQueue::get('inalco_publications_queue');
            foreach ($result as $row) {

                $queue->createItem($row);
                watchdog('inalco_publications', 'Numero de revue / Entity #ID -'.--$row->entity_id);


            }

  //drupal_flush_all_caches(); // ultra lent ...
}


function inalco_publications_queue_worker($data){


   drupal_set_message(t('Dequeued: %item', array('%item' => $data->body_value))); 
   $html_obj = new simple_html_dom();
   $html_obj->load($data->body_value);

   foreach($html_obj->find('li li') as $bt) {

                $node = new stdClass();
                $node->type = "inalco_publication";
                node_object_prepare($node);
                $node->language = LANGUAGE_NONE; 
                $node->title = $bt->children(0)->plaintext;
                $node->uid = 1; 
                $node->body[$node->language][0]['value'] = $bt->outertext; /// remmettre english 
                $node->field_publication_type[$node->language][0]['tid'] = 692;
                $node->path['pathauto'] = FALSE;
                $node->field_auteur_publication_non_ref[$node->language][]['value'] = $bt->children(1)->plaintext;
                $node = node_submit($node); 
                node_save($node);

   }


}
1
  • Its is working fine. I would have run cron fron config and not from ultimate cron .
    – Mamadou
    Aug 13, 2014 at 13:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.