On admin/content/taxonomy/edit/vocabulary/3 submit, I get:

user warning: Duplicate entry 'vocab-3' for key 'PRIMARY' query: INSERT INTO drupal_tvi_settings (`type`, `xid`, `view_id`, `display`, `status`) VALUES ('vocab', 3, 1, 'page_5', 1) in [...]/sites/all/modules/tvi/includes/tvi.query.inc on line 79.

Note that I use the Taxonomy Menu module too.

Comments

NaX’s picture

Priority: Major » Normal
Status: Active » Needs review

I just ran into the same problem. The problem is that mysqli_affected_rows returns 0 on a UPDATE where the record already exists but no data changed.

I have changed the tvi_update_settings() function in tvi/includes/tvi.query.inc to the following.

function tvi_update_settings($settings) {

  if (is_array($settings)) {
   $settings = (object)$settings;	
  }
    
  $exists = db_result(db_query('SELECT COUNT(*) FROM {tvi_settings} WHERE type = "%s" AND xid = %d', $settings->type, $settings->xid));
  
  if ((bool)$exists) {
    $result = db_query(
      "UPDATE {tvi_settings} SET view_name = '%s', display = '%s', status = %d"
       . " WHERE type = '%s' AND xid = %d",
      $settings->view_name,
      $settings->display,
      $settings->status,
      $settings->type,
      $settings->xid
    );
  }
  else {
    $result = db_query(
      "INSERT INTO {tvi_settings} (type, xid, view_name, display, status)"
      . " VALUES ('%s', %d, '%s', '%s', %d)", 
      $settings->type,
      $settings->xid,
      $settings->view_name,
      $settings->display,
      $settings->status    
    );
  }

  return $result;
}
duaelfr’s picture

Status: Needs review » Closed (fixed)

Fixed in the last version.