The short version: activating both "Block user messages" and "Privatemsg Realname Integration" causes an AJAX error in the recipient autocomplete input.
The error was in italian, but I can try to translate it:

An HTTP error occourred in AJAX.
HTTP response code: 500
Path: http://www.example.com/messages/autocomplete
StatusText: Service unavailable (with message)
ResponseText: Recoverable fatal error: Method DatabaseCondition::__toString() must return a string value in privatemsg_realname_query_privatemsg_autocomplete_alter() (row 60 of /path/to/drupal/sites/all/modules/contrib/privatemsg/privatemsg_realname/privatemsg_realname.module).

This are the details:
In a site I activated Real Name and Real Name integration for the Privatemsg module.
The Real Name pattern was something like "[field_first_name] [field_last_name]"
This way everything was working.

Later I had to change the pattern to generate Real Name to something like "[field_company_name]".
I edited all the users to create a new RealName.
Everything was still working.

At the same time I had to filter users by role: users with roles X, Y and Z cannot write messages to other users roles X, Y or Z but only to users with roles A, B or C (I know, it's a lot of roles).
So I activated the "Block user messages" sub-module and created some "Disallow sending message" rules between roles.

Now if I activate the rules, I get the error, otherwise I haven't the feature.
Thanks in advance!

Comments

nessunluogo’s picture

Explaining the problem helped me to find the right way, looking also this issue, and making some debug on privatemsg_realname.module.

It looks like the row 60 won't expect a non string value for $condition['field'], and i think "Block user" adds a DatabaseCondition object which causes the error.

I edited the row from:
if ($condition['field'] == 'u.name') {
to:
if (is_string($condition['field']) && $condition['field'] == 'u.name') {

And it seems everything is working to me.
I don't know if this solution is safe, but I hope it can help you to fix the issue.

ptmkenny’s picture

Status: Active » Needs review
StatusFileSize
new773 bytes

Attaching a patch for review to check it out against testbot. All credit should go to #1.

Status: Needs review » Needs work

The last submitted patch, privatemsg-fix-pm_block-pm_realname-ajax-2007058-2.patch, failed testing.

ptmkenny’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, privatemsg-fix-pm_block-pm_realname-ajax-2007058-2.patch, failed testing.

ptmkenny’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Needs work » Needs review
ptmkenny’s picture

ptmkenny’s picture

Status: Needs review » Closed (duplicate)
caw67’s picture

I have tried it and I think its an error in the og group modul. If I deactivate that it works! Also with realname!