Validation error when using invite block
| Project: | Invite |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
I'm seeing an odd behavior when initiating an invite from the invite block. Entering a single address and clicking invite takes one to the invite page http://domain.com/invite (as expected) where can customize the invite text. However, I get the error "Validation error, please try again. If this error persists, please contact the site administrator." If I then try to submit again from this page and get the same error.
If I visit http://domain.com/invite directly or go to the new invite tab from a user profile as a starting point, the invite works perfectly with no error. Only when initiating from the block does the page generate the error and persist in failing on subsequent attempts from that page.

#1
Ok, I tracked this down to be a problem with block caching. Currently, the block is set to BLOCK_CACHE_PER_ROLE. That is causing the error since the block cache will have data references to the last user to invoke the cache. Caching for the block should either be BLOCK_CACHE_PER_USER or BLOCK_NO_CACHE. I am unsure of which would be the better choice since I am not using invite limits that would need to be updated in the block view. BLOCK_NO_CACHE works for me, but BLOCK_NO_CACHE may be necessary to properly update the invites remaining immediately after sending an invite and not the cached value.
#2
Here's a set of patches to set the block to BLOCK_CACHE_PER_ROLE. The update function in the .install file makes the changes to the block's database entry and the flushes the the block cache so that it starts caching properly.