Make WordPress Core

Ticket #8317: rolefix.patch

File rolefix.patch, 3.6 KB (added by Mr Pete, 16 years ago)

Proposed patch to fix

  • wp-admin/includes/schema.php

     
    351351        add_role('subscriber', 'Subscriber|User role');
    352352
    353353        // Add caps for Administrator role
    354         $role = get_role('administrator');
     354        $role =& get_role('administrator');
    355355        $role->add_cap('switch_themes');
    356356        $role->add_cap('edit_themes');
    357357        $role->add_cap('activate_plugins');
     
    384384        $role->add_cap('level_0');
    385385
    386386        // Add caps for Editor role
    387         $role = get_role('editor');
     387        $role =& get_role('editor');
    388388        $role->add_cap('moderate_comments');
    389389        $role->add_cap('manage_categories');
    390390        $role->add_cap('manage_links');
     
    406406        $role->add_cap('level_0');
    407407
    408408        // Add caps for Author role
    409         $role = get_role('author');
     409        $role =& get_role('author');
    410410        $role->add_cap('upload_files');
    411411        $role->add_cap('edit_posts');
    412412        $role->add_cap('edit_published_posts');
     
    417417        $role->add_cap('level_0');
    418418
    419419        // Add caps for Contributor role
    420         $role = get_role('contributor');
     420        $role =& get_role('contributor');
    421421        $role->add_cap('edit_posts');
    422422        $role->add_cap('read');
    423423        $role->add_cap('level_1');
    424424        $role->add_cap('level_0');
    425425
    426426        // Add caps for Subscriber role
    427         $role = get_role('subscriber');
     427        $role =& get_role('subscriber');
    428428        $role->add_cap('read');
    429429        $role->add_cap('level_0');
    430430}
     
    437437function populate_roles_210() {
    438438        $roles = array('administrator', 'editor');
    439439        foreach ($roles as $role) {
    440                 $role = get_role($role);
     440                $role =& get_role($role);
    441441                if ( empty($role) )
    442442                        continue;
    443443
     
    458458                $role->add_cap('read_private_pages');
    459459        }
    460460
    461         $role = get_role('administrator');
     461        $role =& get_role('administrator');
    462462        if ( ! empty($role) ) {
    463463                $role->add_cap('delete_users');
    464464                $role->add_cap('create_users');
    465465        }
    466466
    467         $role = get_role('author');
     467        $role =& get_role('author');
    468468        if ( ! empty($role) ) {
    469469                $role->add_cap('delete_posts');
    470470                $role->add_cap('delete_published_posts');
    471471        }
    472472
    473         $role = get_role('contributor');
     473        $role =& get_role('contributor');
    474474        if ( ! empty($role) ) {
    475475                $role->add_cap('delete_posts');
    476476        }
     
    482482 * @since 2.3.0
    483483 */
    484484function populate_roles_230() {
    485         $role = get_role( 'administrator' );
     485        $role =& get_role( 'administrator' );
    486486
    487487        if ( !empty( $role ) ) {
    488488                $role->add_cap( 'unfiltered_upload' );
     
    495495 * @since 2.5.0
    496496 */
    497497function populate_roles_250() {
    498         $role = get_role( 'administrator' );
     498        $role =& get_role( 'administrator' );
    499499
    500500        if ( !empty( $role ) ) {
    501501                $role->add_cap( 'edit_dashboard' );
     
    508508 * @since 2.6.0
    509509 */
    510510function populate_roles_260() {
    511         $role = get_role( 'administrator' );
     511        $role =& get_role( 'administrator' );
    512512
    513513        if ( !empty( $role ) ) {
    514514                $role->add_cap( 'update_plugins' );
     
    522522 * @since 2.7.0
    523523 */
    524524function populate_roles_270() {
    525         $role = get_role( 'administrator' );
     525        $role =& get_role( 'administrator' );
    526526
    527527        if ( !empty( $role ) ) {
    528528                $role->add_cap( 'install_plugins' );
  • wp-includes/capabilities.php

     
    533533                //Build $allcaps from role caps, overlay user's $caps
    534534                $this->allcaps = array();
    535535                foreach ( (array) $this->roles as $role ) {
    536                         $role = $wp_roles->get_role( $role );
     536                        $role =& $wp_roles->get_role( $role );
    537537                        $this->allcaps = array_merge( $this->allcaps, $role->capabilities );
    538538                }
    539539                $this->allcaps = array_merge( $this->allcaps, $this->caps );