Cleaner Role Creation Code

I just committed a change to how we populate roles during upgrade. The old way made adding new capabilities to existing roles a pain. The new way handles this nicely and is much easier on the eyes. Furthermore, it actually makes use of our role/cap API instead of going under the covers. What a concept, using our own API. :-)

Give the changeset a look to make sure I didn’t leave out or mangle any caps.

6 comments to Cleaner Role Creation Code

  1. Owen says:

    Hmm. This turns one query via the old update_options() into around 70 distinct queries during the install. But apart from that, cool!

  2. ryan says:

    Yeah, but the extra queries don’t matter too much during upgrade. If they become a problem we can throttle them.

  3. Donncha says:

    I came across a few problems – people were experiencing problems registering because add_cap() requires 2 parameters and upgrade-schema.php calls only have one. Same goes for add_role() except that requires 3..
    I had an eventful morning today!

  4. ryan says:

    The call signatures changed to make those arguments optional. They default to true.

  5. Donncha says:

    Somehow I missed the changes to the capabilities.php and the optional arguments change never made it over. Fixed it now! :)

  6. Joshua says:

    The new code looks so clean I feel like crying. :)
    Nicely done!!