This patch checks permissions passed to drupalCreateUser to ensure that invalid permissions aren't accidentally used.

This is very helpful in spotting out-dated tests and typos.

Requested by Dries http://drupal.org/node/266539#comment-871680, but mentioned several times before.

Comments

boombatower’s picture

StatusFileSize
new1.86 KB

Hmm...patch was there when I previewed.

webchick’s picture

Status: Needs review » Needs work

Oh, *awesome*!

One suggestion I have is to add static caching to that $available array. It's probably expensive to re-generate that each time drupalCreateUser is called.

see http://www.lullabot.com/articles/a_beginners_guide_to_caching_data for more info.

webchick’s picture

Oh, also, you're missing a patch to simpletest.test to make sure this function is working properly. ;)

damien tournoud’s picture

Hum. Just a though here, why not implement that check in user_access() in order to enforce it everywhere in Drupal? I remember that this loosely typed permission bit me several times.

boombatower’s picture

Status: Needs work » Needs review
StatusFileSize
new4.66 KB

Updated to include test and caching.

boombatower’s picture

Any thoughts on #4. I would be for it.

dries’s picture

I would leave #4 for another issue. I'm not sure I'd want to check the permissions for every page view. I'd try to work it into devel.module or so.

boombatower’s picture

Ok, so any reviews? :)

catch’s picture

Status: Needs review » Reviewed & tested by the community

It's a good idea and all the tests pass, RTBC.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Commited to CVS HEAD. Thanks again, boombatower.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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