The autocomplete fields at /messages/blocked includes user roles (for those that have permission) in addition to individual users. If you try to block a role from that form, you get a fatal error. We should probably prevent roles from showing up in the autocomplete (since blocking roles is not supported from that form). And if someone actually tries to manually enter a role for blocking, we need some error handling to prevent the fatal error from being displayed.

Just for completeness in this report, here's the fatal error:

Notice: Undefined property: stdClass::$uid in pm_block_user_has_blocked() (line 183 of/Users/benkaplan/git/drupal/sites/all/modules/privatemsg-DRUPAL-7--1/pm_block_user/pm_block_user.module).
Notice: Undefined property: stdClass::$uid in pm_block_user_block_validate() (line 159 of/Users/benkaplan/git/drupal/sites/all/modules/privatemsg-DRUPAL-7--1/pm_block_user/pm_block_user.pages.inc).
Notice: Undefined property: stdClass::$uid in pm_block_user_block_submit() (line 186 of/Users/benkaplan/git/drupal/sites/all/modules/privatemsg-DRUPAL-7--1/pm_block_user/pm_block_user.pages.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'author' cannot be null: INSERT INTO {pm_block_user} (author, recipient) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => 1 )in pm_block_user_block_submit() (line 191 of/Users/benkaplan/git/drupal/sites/all/modules/privatemsg-DRUPAL-7--1/pm_block_user/pm_block_user.pages.inc).

--Ben

CommentFileSizeAuthor
#1 privatemsg_block_only_user.patch7.29 KBBerdir
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Status: Active » Needs review
FileSize
7.29 KB

It is actually even more broken right now because the autocomplete path is wrong.

This patch should fix both things suggested above and also adds a new hook to the autocomplete and documents that and another one that was found to be undocumented ;)

BenK’s picture

Status: Needs review » Reviewed & tested by the community

The patch works perfectly... roles don't show up in autocomplete, plus even if user types in a role manually, he is prevented from blocking with a user-friendly message. This is RTBC.

--Ben

Berdir’s picture

Version: 7.x-1.x-dev »
Status: Reviewed & tested by the community » Patch (to be ported)

Thanks, commited.

A part of this needs to be ported back to 6.x-2.x...

Berdir’s picture

Status: Patch (to be ported) » Fixed

Ported and commited!

Status: Fixed » Closed (fixed)

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