function taxonomy_edge_rebuild_order in Taxonomy Edge 6
Same name and namespace in other branches
- 8 taxonomy_edge.rebuild.inc \taxonomy_edge_rebuild_order()
- 7.2 taxonomy_edge.rebuild.inc \taxonomy_edge_rebuild_order()
- 7 taxonomy_edge.rebuild.inc \taxonomy_edge_rebuild_order()
Rebuild the sorted tree.
3 calls to taxonomy_edge_rebuild_order()
- TaxonomyEdgeTreeTestCase::testOrder in tests/
tree.test - taxonomy_edge_cron in ./
taxonomy_edge.module - Implements hook_cron().
- taxonomy_edge_update_6101 in ./
taxonomy_edge.install - Update edge table with serial, vocabulary id and indexes, and add order table.
2 string references to 'taxonomy_edge_rebuild_order'
- taxonomy_edge_rebuild_all_batch in ./
taxonomy_edge.rebuild.inc - Start batch job for rebuild of edges and 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) {
$vocabulary = taxonomy_vocabulary_load($vid);
if (!$vocabulary) {
$context['success'] = FALSE;
$context['message'] = t('Invalid vocabulary ID: %vid', array(
'%vid' => $vid,
));
return;
}
// Acquire lock
if (!lock_acquire('taxonomy_edge_rebuild_edges_' . $vid)) {
$context['success'] = FALSE;
$context['message'] = t('Could not acquire lock!');
return;
}
$tx = _taxonomy_edge_db_transaction();
$time = microtime(TRUE);
taxonomy_edge_invalidate_order($vid);
db_query("DELETE FROM {term_edge_order} WHERE vid = %d", $vid);
db_query("INSERT INTO {term_edge_order} (vid, parent, eid)\n SELECT %d, op.parent, op.eid\n FROM {term_edge} op\n WHERE op.vid = %d\n ORDER BY " . _taxonomy_edge_generate_term_path_query('op.tid'), $vid, $vid);
$total_rows = db_affected_rows();
$context['success'] = TRUE;
$context['finished'] = 1;
$context['message'] = t('%name sorted: %rows edges in %time seconds', array(
'%rows' => $total_rows,
'%time' => sprintf("%.03f", microtime(TRUE) - $time),
'%name' => $vocabulary->name,
));
$context['results'][] = $context['message'];
db_query("INSERT INTO {term_edge_order} (vid) VALUES(%d)", -$vid);
lock_release('taxonomy_edge_rebuild_edges_' . $vid);
}