Skip to content

Commit d5ef2da

Browse files
committed
Normalize all fields with underscores when filtering
1 parent ed9f128 commit d5ef2da

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/User_Application_Password_Command.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,23 +165,22 @@ static function ( $a, $b ) use ( $orderby, $order ) {
165165

166166
$fields = self::APPLICATION_PASSWORD_FIELDS;
167167

168+
// Avoid confusion regarding the dash/underscore usage.
169+
foreach ( [ 'app-id', 'last-used', 'last-ip' ] as $flag ) {
170+
if ( array_key_exists( $flag, $assoc_args ) ) {
171+
$underscored_flag = str_replace( '-', '_', $flag );
172+
$assoc_args[ $underscored_flag ] = $assoc_args[ $flag ];
173+
unset( $assoc_args[ $flag ] );
174+
}
175+
}
176+
168177
foreach ( $fields as $field ) {
169-
if (
170-
! array_key_exists( $field, $assoc_args )
171-
&&
172-
! ( 'app_id' === $field && array_key_exists( 'app-id', $assoc_args ) )
173-
) {
178+
if ( ! array_key_exists( $field, $assoc_args ) ) {
174179
continue;
175180
}
176181

177182
$value = Utils\get_flag_value( $assoc_args, $field );
178183

179-
// Avoid confusion regarding the dash/underscore between creation flag
180-
// and querying field name.
181-
if ( 'app_id' === $field && array_key_exists( 'app-id', $assoc_args ) ) {
182-
$value = Utils\get_flag_value( $assoc_args, 'app-id' );
183-
}
184-
185184
$application_passwords = array_filter(
186185
$application_passwords,
187186
static function ( $application_password ) use ( $field, $value ) {

0 commit comments

Comments
 (0)