The forum_node_form_alter function used in the core Forum module attempts to set the default value of taxonomy_forums by using the forum id in the URL of the node/add// page. However, when the form is being rebuilt as part of an Ajax process, the URL is not the expected node/add// and the value retrieved by the hardcoded arg(3) callback is not the forum tid.
This results in forum posts being posted outside of the expected forum where a user without edit access to the taxonomy_forums field uploads a file to a forum topic, or triggers some other kind of ajax form rebuild.
Comment | File | Size | Author |
---|---|---|---|
#5 | edit_forum_posts_lose-2826373-5.patch | 1.69 KB | cebasqueira |
#2 | forum-posts-lose-their-forum-2826373-2.patch | 1.71 KB | MrDaleSmith |
Comments
Comment #2
MrDaleSmith CreditAttribution: MrDaleSmith at CTI Digital commentedAdded patch that checks in the $form_state for an existing default value before resorting to arg(3).
Comment #4
cebasqueira CreditAttribution: cebasqueira commentedComment #5
cebasqueira CreditAttribution: cebasqueira commentedComment #7
cebasqueira CreditAttribution: cebasqueira commentedComment #8
larowlanThanks!
I think at this stage it would be in $form_state['rebuild'] and in which case the value should be in
$form_state['values']['taxonomy_forums'][$langcode]
- can you check, as that is the normal approach to rebuilding a form from previous values. The problem with using the default value is the user may have changed the default before the ajax operation, and in which case the original value would be used.Also, we need a test to go with this.
Comment #9
MrDaleSmith CreditAttribution: MrDaleSmith at CTI Digital commentedThe rebuild process replaces any value information from the $form_state already, but as the user doesn't have access to the field, the value isn't carried across into the $form_state.
I'll see if I can work out how to do testing and update the patch. :)
Comment #10
Antonio W. Mucciolo Jr. CreditAttribution: Antonio W. Mucciolo Jr. as a volunteer and at CI&T commented+RTBC
Comment #11
larowlanMy review hasn't been addressed, nor have the tests been added
Comment #12
MrDaleSmith CreditAttribution: MrDaleSmith at CTI Digital commentedRunning the forum tests locally I get multiple fails before I've made any changes, which makes it hard to create a new test for this behaviour. Can't see an issue for this in the issue queue: is this a known problem, or is it something that only occurs to me locally?