To Reproduce

Login as user that has OG permission 'update own page content' but lacks 'create page content' in a group. Go to create page form. Said group is listed in group audience field. Select that group, fill out the form, and create page content.

Expected behavior

Said group will not be listed in group audience field and creation of page in group will not be allowed.

Reason + patch

The access check added in #1541672: Don't check "create" access in OgSelectionHandler::buildEntityFieldQuery() to OgSelectionHandler only checks that $node exists or $node->uid == $user->uid, but does not check $node->nid. At some point in the form render process, a stub $node is created, so these checks succeed even though the content does not yet exist.

This patch checks $node->nid explicitly. Patch is against 7.x-2.x.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

Nice. Any chance for a test, to prevent regressions?

ezheidtmann’s picture

With pleasure. I'll work on it now.

ezheidtmann’s picture

ezheidtmann’s picture

First patch had an unused test...() method. This one has same functionality, no cruft.

amitaibu’s picture

Status: Needs review » Needs work

Thanks!

  • Lets move the test under OgNodeAccess
  • The test seems to be trying to do a lot. Can't we just assert node_access() with the permission and without?
ezheidtmann’s picture

Assigned: ezheidtmann » Unassigned

I won't have a chance to work on this patch again any time soon, so please feel free to move it to where it needs to be.

And (I believe) we have to do the test this way because the bug is in OgSelectionHandler. Even without this patch, og_user_access_entity() still returns the appropriate value.

(Perhaps there is deeper bug that doesn't double check the permissions upon group content creation?)

amitaibu’s picture

Status: Needs work » Needs review
FileSize
2.95 KB

Completely overhauled test.

amitaibu’s picture

Committed.

amitaibu’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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