Since privatemsg_user_load() is the user recipient type's load function, and recipient load functions are supposed to handle arrays of ids, it should too.

This change makes it valid to pass 'user_[uid]' to the _privatemsg_generate_user_array() function, which allows for standardization when dealing with lots of recipient types.

Patch forthcoming.

CommentFileSizeAuthor
#1 1033338-user-load-array.patch1.64 KBte-brian

Comments

te-brian’s picture

Status: Active » Needs review
StatusFileSize
new1.64 KB

First stab. I'm sure Berdir will have comments on my comments :)

berdir’s picture

About the comments, no :)

http://ch2.php.net/array_intersect_key is a nice function but PHP 5 only and we currently don't require that for the Drupal 6 versions. So I guess the question is if we want to drop PHP 4 support for a handy little function that saves us 3 lines of code or so :)

I'm not sure how many are still using PHP 4 but when we accidently added something that required PHP 5 in the past, we sooner or later got a bug report about it. I guess we can try again and see what happens... :)

Tests would be good since just passing in user_1 triggers like 4 warnings. But we can do that while writing tests for #1033378: $subject in privatemsg_get_link() should be url encoded

berdir’s picture

No tests for this in #1033378: $subject in privatemsg_get_link() should be url encoded because the needed URL can't be generated by privatemsg_get_link() but it should be very similiar to write one, wanna try?

See also http://blog.worldempire.ch/de/story/writing-automated-tests-drupal-7

(not many differences re: test writing in D6 and 7)

BenK’s picture

SUbscribing

berdir’s picture

Version: » 7.x-1.x-dev
Status: Needs review » Patch (to be ported)

Decided to commit this because it is tested *a lot* with the change in #1034378: Add more recipient types to 'list' sql query. :)

Will need to verify how the situation is in D7, since core is already providing a statically cached user load function. Will maybe require some changes too.

berdir’s picture

Status: Patch (to be ported) » Closed (duplicate)