db_query('DELETE FROM {node_revisions} nr WHERE nr.vid NOT IN (SELECT n.vid FROM {node} n)');
You don't want to delete all the revisions: You want to delete all but the current revision.
在content-type-form里面有个选项create a new revision 如果选择了这个 则每次修改node的时候 都会生成一个新的node revision
也有这样的选择
function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id) { //drupal_set_message("Form ID is : " . $form_id); switch($form_id) { case 'CONTENT_TYPE_node_form': //dpm($form); $form['actions']['submit']['#submit'][] = 'revision_control_node_form_submit'; $form['actions']['submit']['#submit'] = array_reverse($form['actions']['submit']['#submit']); // reverse array to put our submit handler first break; } }
function revision_control_node_form_submit($form, &$form_state) { if($form_state['values']['your_taxonomy_field'] == 'your_value') { $form_state->revision = 1; } }
http://stackoverflow.com/questions/21451567/how-to-enable-disable-revision-in-drupal-7