Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/27/2019 04:53:16 AM (4 years ago)
Author:
imath
Message:

Only load BP REST API Avatar Controllers when avatar uploads are on

  • Move the loading of the BP_REST_Attachments_Member_Avatar_Endpoint controller into the xProfile component's class. User Avatar is an xProfile feature.
  • Make sure to check the community administrator allowed member avatar uploads before loading this controller.
  • Make sure to check the community administrator allowed group avatar uploads before loading BP_REST_Attachments_Group_Avatar_Endpoint.

Fixes #8151 (Branch 5.0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/tests/phpunit/testcases/core/class-bp-component.php

    r12463 r12483  
    3333            'BP_REST_Components_Endpoint',
    3434            'BP_REST_Members_Endpoint',
    35             'BP_REST_Attachments_Member_Avatar_Endpoint',
    3635        ) );
    3736    }
     
    4948        $this->assertSame( $bp->unit_test_rest->controllers, array(
    5049            'BP_REST_Components_Endpoint',
    51             'BP_REST_Attachments_Member_Avatar_Endpoint',
    5250        ) );
    5351    }
     
    6664            'BP_REST_Components_Endpoint',
    6765            'BP_REST_Members_Endpoint',
     66        ) );
     67    }
     68
     69    public function test_rest_api_init_for_xprofile_component() {
     70        $bp_xprofile = new BP_XProfile_Component();
     71        $bp          = buddypress();
     72
     73        $bp_xprofile->rest_api_init();
     74
     75        $this->assertSame( $bp->unit_test_rest->controllers, array(
     76            'BP_REST_XProfile_Fields_Endpoint',
     77            'BP_REST_XProfile_Field_Groups_Endpoint',
     78            'BP_REST_XProfile_Data_Endpoint',
    6879            'BP_REST_Attachments_Member_Avatar_Endpoint',
    6980        ) );
    7081    }
     82
     83    public function test_rest_api_init_for_xprofile_component_without_avatar_enabled() {
     84        add_filter( 'bp_disable_avatar_uploads', '__return_true' );
     85
     86        $bp_xprofile = new BP_XProfile_Component();
     87        $bp          = buddypress();
     88
     89        $bp_xprofile->rest_api_init();
     90
     91        remove_filter( 'bp_disable_avatar_uploads', '__return_true' );
     92
     93        $this->assertSame( $bp->unit_test_rest->controllers, array(
     94            'BP_REST_XProfile_Fields_Endpoint',
     95            'BP_REST_XProfile_Field_Groups_Endpoint',
     96            'BP_REST_XProfile_Data_Endpoint',
     97        ) );
     98    }
    7199}
Note: See TracChangeset for help on using the changeset viewer.