I use taxonomy_single_tag module and Unitag, and both modules worked fine together before I upgraded Unitag to 6.x-1.0-beta3.
Now when I save node with unquoted tag (I use "Tag (single select)" option in vocabulary serttings), this tag is saved quoted.

If I disable Unitag, saving works fine again. If I leave Unitag ebabled and disable taxonomy_single_tag, it works as before too. But I need both modules, so I replaced Unitag 6.x-1.0-beta3 with 6.x-1.0-beta2 until the conflict is not resolved.

I tried to understand what's the matter, looking on the diff between beta3 and beta2, but I can't do this.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Zen’s picture

In what way is it not working? Error message?
Please also link to the conflicting module.

Thanks.

quotesBro’s picture

Thank you for quick respond.
Conflictiing module: http://drupal.org/project/taxonomy_single_tag

The problem is the term without any quotes is being saved quoted. (we want Term --> but get "Term")

quotesBro’s picture

I guess this code from taxonomy_single_tag.module should help:

function taxonomy_single_tag_submit($form, &$form_state) {
  $values = &$form_state['values'];
  if (!empty($values['taxonomy'])) {
    $terms = &$values['taxonomy']['tags'];
    // Free tagging vocabularies do not send their tids in the form,
    // so we'll detect them here and process them independently.
    // As only one tag is allowed commas requires quoting the phrase
    // while quotes are double escaped.
    if (isset($terms)) {
      $vids_single_tag = variable_get('taxonomy_single_tag:vids', array());
      foreach($terms as $vid => $term_name) {
        if (in_array($vid, $vids_single_tag)) {
          if (strpos($term_name, ',') !== FALSE || strpos($term_name, '"') !== FALSE) {
            $term_name = '"'. str_replace('"', '""', $term_name) .'"';
          }
          $terms[$vid] = $term_name;
        }
      }
    }
  }
}
bradya’s picture

You can fix this by substituting the following code in the taxonomy_single_tag.module

if (strpos($term_name, ',') !== FALSE || strpos($term_name, '"') !== FALSE) {
           	$term_name = '"'. str_replace('"', '""', $term_name) .'"';
          }

with

if ($term_name[0]=='"' && $term_name[strlen($term_name)-1]=='"')
	{
		$term_name = substr($term_name, 1, strlen($term_name) - 2);
	}
if (strpos($term_name, ',') !== FALSE || strpos($term_name, '"') !== FALSE) {
          	$term_name = '"'. str_replace('"', '""', $term_name) .'"';
}
else {$term_name='"'.$term_name.'"';}

Which basically prevents single_tags from escape the enclosing double quotes of the tag.

quotesBro’s picture

Thanks. It helps in case of the tag without commas inside. But if the tag includes commas - like Test. One, two, three - we get Test. One", "two", "three

quotesBro’s picture

Version: 6.x-1.0-beta3 » 6.x-1.x-dev
Status: Active » Needs review
FileSize
1.18 KB

// my mistake

quotesBro’s picture

FileSize
1.38 KB

Don't look at the previous patch, it was uploaded by mistake.
Now I'm attaching the patch against 6.x-1.x-dev which solves the problem with http://drupal.org/project/taxonomy_single_tag module.

Also I've attached the patch for taxonomy_single_tag module in #1463802: taxonomy_single_tag_submit is being called more than once.

Zen’s picture

Category: bug » feature
Status: Needs review » Needs work

Hello Mikhail,

Would it be fair to say that while your patch fixes things with the taxonomy single tag module, what we are introducing in effect is a new feature where we treat the "multiple select" checkbox differently?

Comments for the new code will also be appreciated.

Thanks,
-K