I have a fresh install of privatemsg and I receive the following warnings when clicking on 'Send this user a private message' link:

Strict warning: Only variables should be passed by reference in _privatemsg_generate_user_array() (line 95 of /opt/lampp/htdocs/xxxxx/sites/all/modules/privatemsg/privatemsg.module).

Sometimes the line number is 88. The 'Messages' page does not show any error or warning, nor when I just click on 'Compose new message' link. The message is sent correctly though.

Can this be related to Tokens module? Because in the page that I get this warning, the "To" field is preloaded with the clicked user name along with token-like entry. It says "User Two [user: user2]".
(where 'User Two' is the user's full name and 'user2' is the userid).

Update:
Looks like the user name displayed in that format may be because of 'Realname' module.
Meanwhile, I've suppressed the warnings by putting the parameters to the 'array_shift' functions in line 88 and 95 into a variable as suggested by the warning message.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cadius’s picture

I've got this too. What was the code change to fix this?

m2jalali’s picture

+1

fredfab’s picture

I've got this too.

Anandkumar said :
"Meanwhile, I've suppressed the warnings by putting the parameters to the 'array_shift' functions in line 88 and 95 into a variable as suggested by the warning message."

It sems to be interesting but I don't know how to do this ?
Someone could help ?

Anandkumar’s picture

Here's what I replaced my line 88 with:

    $user_ids = privatemsg_user_load_multiple(array($uid));
    if ((int)$uid > 0 && ($account = array_shift($user_ids))) {

And, these lines replace line 95:

        $temp_load = $type_info['load'](array($id));
        if ($participant = array_shift($temp_load)) {

Sorry, no time to create patches.

fredfab’s picture

Thank you Anandkumar! It's perfect.

Edy Gorbacev’s picture

thanks..

almost confused.. but now understand hehehe..
This is in line 95 :

if ($participant = array_shift($type_info['load'](array($id)))) {

and i replace it with yours:

$temp_load = $type_info['load'](array($id));
if ($participant = array_shift($temp_load)) {

and i move to line 88.. do the same thing hahaha.. becouse if i replace line 88 first.. than it will make me confuse becouse the line 95 will move to row 97... lol..

Thank you very much..

Berdir’s picture

makes sense, can you provide this as a patch?

daniela basualdo’s picture

+1

offerman’s picture

Here's the patch I created from #4.

Berdir’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, privatemsg-getting_strict_warnings.patch, failed testing.

pfrenssen’s picture

Version: 7.x-1.2 » 7.x-2.x-dev
Status: Needs work » Needs review
FileSize
1.12 KB

Here's a proper patch rolled against 7.x-2.x from the change proposed in #4.

pfrenssen’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
FileSize
1.12 KB

And here is the same patch rolled against 7.x-1.x.

Berdir’s picture

Status: Needs review » Fixed

Thanks, commited both patches.

Status: Fixed » Closed (fixed)

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

lachokun’s picture

I had the same issue there... thanks Anandkumar for the fix! xDDD

lachokun’s picture

Issue summary: View changes

Added and update regarding Realnames.