Making WordPress.org


Ignore:
Timestamp:
11/20/2018 07:03:45 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Prevent a user removing themselves as the committer, if they're the only committer.

Fixes #3923.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-committers.php

    r7420 r7876  
    140140        $plugin_slug = $request['plugin_slug'];
    141141
     142        // Prevent a committer removing themselves, if they're the only committer.
     143        if ( $user->user_login == wp_get_current_user()->user_login ) {
     144            $committers = Tools::get_plugin_committers( $plugin_slug );
     145            if ( count( $committers ) == 1 && in_array( $user->user_login, $committers ) ) {
     146                return new WP_Error( 'failed', __( 'Sorry, you must have at least one committer.', 'wporg-plugins' ) );
     147            }
     148        }
     149
    142150        $result = Tools::revoke_plugin_committer( $plugin_slug, $user );
    143151        if ( ! $result ) {
Note: See TracChangeset for help on using the changeset viewer.