What would the minumum parameter for drupal_bootstrap needed for an ajax call to a drupal url which points to a callback that only has a return statement in it

Events happening in the community are now at Drupal community events on www.drupal.org.
mitchelljj's picture

Any reason why having a javascript timer fire every 2.5 second for an ajax
request to my own callback(listed below) that all it does is return the

contents of 2 _session variables would take up so much resources?

 function refreshcarttimer() {
     print($_SESSION['num_items'] . ',' .  $_SESSION['uc_price']);
     return;
 }

 /**
  * Implementation of hook_menu().
  */

 function product_type_menu() {
   $items = array();

   $items['cart/refreshcarttimer'] = array(
     'title' => 'Refresh Shopping Cart',
     'description' => 'Refresh Shopping Cart',
     'page callback' => 'refreshcarttimer',
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
   );

return $items;

I found out that you could put the following within your function module to help with performance when calling a page:

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);

// Choose the minimum bootstrap level necessary for your module.

If all I want to do is just send an ajax call to a drupal url which points to a callback that only has a return statement in it (originally I returned the contents of 2 session variables but I will eliminate that if it causes additional overhead). What would the minumum parameter for drupal_bootstrap needed for the scenario listed above?
According to the documentation it appears to be DRUPAL_BOOTSTRAP_CONFIGURATION.
Am I correct that I should use DRUPAL_BOOTSTRAP_CONFIGURATION as the parameter?

Thanks,

John

Comments

Have a look at the

smk-ka's picture

Have a look at the High-performance JavaScript callback handler project, it allows you to comfortably register custom AJAX callback functions, bootstrap to a custom level and even load required modules or include files.

To also answer your question: the minimum bootstrap level in your case obviously would be DRUPAL_BOOTSTRAP_SESSION, since before that the session variables are not available. The JS module always bootstraps to DRUPAL_BOOTSTRAP_PATH, since that gives access to some more common functions and takes almost no extra time. See the README for more information.

-Stefan

High performance

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: