You are here

function _boost_cache_insert in Boost 6

Shutdown function, gets called at the very end of node creation.

Node is now created, thus we can get the node path and set the boost_cache table.

1 string reference to '_boost_cache_insert'
boost_nodeapi in ./boost.module
Implementation of hook_nodeapi(). Acts on nodes defined by other modules.

File

./boost.module, line 1143
Provides static file caching for Drupal text output. Pages, Feeds, ect...

Code

function _boost_cache_insert() {
  static $processed = FALSE;
  if ($processed) {
    return;
  }
  global $_boost;
  if (empty($_boost['new_nodes'])) {
    return FALSE;
  }

  // Ensure we're in the correct working directory, since some web servers (e.g. Apache) mess this up here.
  chdir(dirname($_SERVER['SCRIPT_FILENAME']));

  // Load node
  foreach ($_boost['new_nodes'] as $nid) {
    $node = boost_node_get_basics($nid);
    if (!$node) {
      continue;
    }
    $router_item = array();
    $router_item['page_callback'] = 'node';
    $router_item['page_type'] = $node->type;
    $router_item['page_id'] = $node->nid;

    // Set DB defaults
    $expire = 0;
    $lifetime = -1;
    $push = -1;
    $timer = 0;
    $timer_average = 0;
    $extension = BOOST_FILE_EXTENSION;

    // Get list of base urls for this node
    $base_urls = array();
    foreach (boost_get_base_urls($node) as $domain_id) {
      foreach ($domain_id as $base) {
        $base_urls[] = $base . $node->path;
      }
    }

    // Insert each url into the DB
    foreach ($base_urls as $url) {
      $parts = parse_url($url);
      $file_path = boost_cache_directory($parts['host'], FALSE);
      $filename = boost_file_path($node->path, FALSE, BOOST_FILE_EXTENSION, $file_path);
      boost_put_db($filename, $expire, $lifetime, $push, $router_item, $timer, $timer_average, $extension, $url, $file_path);
    }
  }
  $processed = TRUE;
}