Ran into a problem on node form add: there is no nid assigned, so when you save the node the restrictions don't get saved along with it. The node doesn't exist, so at that point in the form it has no nid -- a value of nid=0 was being added to {restricted content}.
What the user would see is the access restriction just not being saved. They'd have to go back in and edit the saved node, and then set the access again before it would "take." I don't have time to fix it properly, so all I did was insert this:
function restricted_content_form_alter(&$form, $form_state, $form_id) {
+ $nid = $form['nid']['#value'];
// ...and then I added isset($nid)
- elseif ($form['#id'] == 'node-form') {
+ elseif ($form['#id'] == 'node-form' && isset($nid)) {
Basically what this means is that the Restricted Access form just doesn't show up AT ALL on node/add, only on node/edit. In terms of usability it at least stops the confusion and gets rid of the creation of dud db entries, but it means you have to tell users to go back in. You'd have to tell them that anyway to get it to work, but at least this way they won't somehow think they've already done it.
(I didn't roll a patch because of the weird patch problems earlier in the queue to do with creating defaults per content type. But this should be enough to help those who are going wha?? :)
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | newnode0fix-826350.patch | 1.61 KB | eiriksm |
| #2 | newnode0fix-826350.patch | 1.62 KB | JuliaKM |
Comments
Comment #1
JuliaKM commentedJust want to note that I've experienced the same problem. Here are the steps to reproduce:
1) Go to any node/add form
2) Select a role in the restricted access form
3) Save the node
4) Go back to the node after saving. There are no roles assigned
5) Go to the restricted_content database table. There is a record with a nid of 0 and the roles you selected
Comment #2
JuliaKM commentedHere's a patch that fixes the problem by doing adding an insert hook into the database to insert a new record for new nodes. This was the only way I found to get around the problem of not knowing the nid in restricted_content_node_form_submit. Additionally, I added a check in restricted_content_node_form_submit to see if the nid is set.
I've upgraded the priority to major because without the patch or the temporary fix mentioned in the issue description, incorrect values are getting inserted into the database.
Comment #3
eiriksmI can confirm that this is a bug appearing here as well. Can also confirm that this patch fixes the issue.
There is some indenting errors however, but attached an updated version.
A long shot that this will be commited i guess, but setting to RTBC anyway.
Comment #4
JuliaKM commentedThanks for re-rolling! Hoping that this patch gets committed. FYI - I contacted the maintainer around the time that I posted the patch but did not hear back.