Making WordPress.org

Changeset 2744


Ignore:
Timestamp:
03/14/2016 01:58:14 PM (9 years ago)
Author:
ocean90
Message:

Translate, Rosetta Roles: In WPorg_GP_Rosetta_Roles::is_approver_for_locale() don't use in_array() to check whether a capability exists.

Capabilities are stored as [ $cap => bool ], which means in_array( 'translation_editor', array( 'contributor' => true ) ) returns alway true (if the strict parameter isn't set).

See #1352.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-rosetta-roles/wporg-gp-rosetta-roles.php

    r2275 r2744  
    179179        }
    180180
    181         $is_approver = in_array( self::TRANSLATION_EDITOR_ROLE, $user->$cap_key ) || in_array( self::GENERAL_TRANSLATION_EDITOR_ROLE, $user->$cap_key );
     181        $capabilities = $user->{$cap_key};
     182        $is_approver = ! empty( $capabilities[ self::TRANSLATION_EDITOR_ROLE ] ) || ! empty( $capabilities[ self::GENERAL_TRANSLATION_EDITOR_ROLE ] );
    182183        $cache[ $user_id ][ $locale_slug ] = $is_approver;
    183184
Note: See TracChangeset for help on using the changeset viewer.