In step 3 below, privatemsg_filter_add_tags($form_state['values']['thread_id'], $tag_ids)the last parameter $tags_ids should be $tag_id


function privatemsg_filter_form_submit($form, &$form_state) {
  if (isset($form_state['values']['submit'])) {
    $tags = explode(',', $form_state['values']['tags']);

    // Step 1 - Delete all tag mapping. I cannot think of a better way to remove tags that are no longer in the textfield, so ideas welcome.
    privatemsg_filter_remove_tags($form_state['values']['thread_id']);

    // Step 2 - Get the id for each of the tags.
    $tag_ids = privatemsg_filter_create_tags($tags);

    // Step 3 - Save all the tagging data.
    foreach ($tag_ids as $tag_id) {
      privatemsg_filter_add_tags($form_state['values']['thread_id'], $tag_ids); // <================== $tag_ids should be $tag_id.
    }
    drupal_set_message(t('Tagging information has been saved.'));
  }
}

I don't have time right now to create a patch for this, but I might get to it soon. It is a trivial change though.

Comments

berdir’s picture

Status: Active » Needs review
StatusFileSize
new2.82 KB

Good catch.

Attached is a patch that does fix this and also adds some tests which should catch that bug. They aren't that good but the idea is that the tests are continously improved when bugs are fixed or features added.

berdir’s picture

Version: » 6.x-1.x-dev
berdir’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs review » Patch (to be ported)

Fixed in 6.x-1.x-dev. Before porting it to D7, #444264: Add tagging actions to message listing needs to be fixed. Actually, this can probably be integrated into the other patch.

berdir’s picture

Status: Patch (to be ported) » Fixed

Setting this to fixed as I'm going to commit this fix together with #444264: Add tagging actions to message listing

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.