You are here

function taxonomy_edge_rebuild_order in Taxonomy Edge 7.2

Same name and namespace in other branches
  1. 8 taxonomy_edge.rebuild.inc \taxonomy_edge_rebuild_order()
  2. 6 taxonomy_edge.rebuild.inc \taxonomy_edge_rebuild_order()
  3. 7 taxonomy_edge.rebuild.inc \taxonomy_edge_rebuild_order()

Rebuild the sorted tree.

1 string reference to 'taxonomy_edge_rebuild_order'
taxonomy_edge_rebuild_order_batch in ./taxonomy_edge.rebuild.inc
Start batch job for rebuild of order

File

./taxonomy_edge.rebuild.inc, line 171
This file contains the functions for reuilding various tables.

Code

function taxonomy_edge_rebuild_order($vid, &$context) {

  // Acquire lock
  if (!lock_acquire('taxonomy_edge_rebuild_edges_' . $vid)) {
    $context['success'] = FALSE;
    $context['message'] = t('Could not acquire lock!');
    return;
  }
  $tx = db_transaction();
  $time = microtime(TRUE);
  db_query("DELETE FROM {taxonomy_term_edge_order} WHERE vid = :vid", array(
    ':vid' => $vid,
  ));
  $total_rows = db_query("\n    INSERT INTO {taxonomy_term_edge_order} (vid, pid)\n    SELECT :vid, op.pid\n    FROM {taxonomy_term_edge_path} op\n    WHERE op.vid = :vid\n    ORDER BY " . _taxonomy_edge_generate_term_path_query('op.pid'), array(
    ':vid' => $vid,
  ))
    ->rowCount();
  $context['finished'] = 1;
  $context['results'][] = t('Trees sorted: %rows leaves in %time seconds', array(
    '%rows' => $total_rows,
    '%time' => microtime(TRUE) - $time,
  ));
  lock_release('taxonomy_edge_rebuild_edges_' . $vid);
}