On my site, I have two vocabularies that can be applied to project_release nodes: api, and os. I've noticed a problem where if a user who does not have 'administer projects' permissions edits a release node, even if it's just the body that's getting edited, when the node is saved again the value of the api taxonomy term that was associated with the release gets erased. This doesn't happen for users with 'administer projects' permissions. Furthermore, the select box for the api term wasn't added to the edit form if the user was not adding a release node but instead was editing one that existed already.

I have tracked this problem down to the project_release_load() function. In my case the query in that function was actually returning two tid values, but the first row returned was not the tid that is associated with api version but instead was that associated with the OS version. Later, when project_release_alter_release_form() gets called it doesn't have the right value for $node->version_api_tid and therefore the control for this taxonomy term is not added to the form. Thus, when the release node is saved the taxonomy term is removed since it wasn't added to the edit form in the first place.

I've attached a patch that modifies the query in project_release_load() to match the vid returned by _project_release_get_api_vid(). I've tested this patch on my site and it does what I want it to do and I haven't found any side effects yet.

CommentFileSizeAuthor
#1 api_tid.patch1.09 KBhunmonk
project_release_load_api_vid_0.txt909 bytesaclight

Comments

hunmonk’s picture

StatusFileSize
new1.09 KB

this is a needed fix. updated patch:

  • i prefer the vid restriction in the WHERE clause -- having it in the INNER JOIN makes the query harder to understand IMO.
  • changed $tid -> $api_tid -- more self documenting.
  • Add a brief code comment to describe what's going on there.

tested and working on postgres. please test and confirm on mysql, and RTBC if she's ready!

aclight’s picture

Status: Needs review » Reviewed & tested by the community

looks good on mysql. RTBC

hunmonk’s picture

Status: Reviewed & tested by the community » Fixed

fixed in HEAD, 4.7.x-2.x. doesn't look like 4.7.x-1.x used taxo for releases in that way, so nothing to do there.

Anonymous’s picture

Status: Fixed » Closed (fixed)