Skip to content

Commit aff0437

Browse files
authored
fix: "key" argument for MetaData fields fixed (#921)
1 parent 922ba37 commit aff0437

File tree

7 files changed

+91
-100
lines changed

7 files changed

+91
-100
lines changed

bin/_lib.sh

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ install_wordpress() {
3535
composer require --dev --no-interaction -W \
3636
johnpbloch/wordpress:* \
3737
wp-graphql/wp-graphql-jwt-authentication \
38-
axepress/wp-graphql-headless-login \
3938
wpackagist-plugin/woocommerce \
4039
wpackagist-plugin/woocommerce-gateway-stripe \
4140
wpackagist-plugin/wp-graphql \

composer.lock

+51-51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/type/object/class-meta-data-type.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -88,31 +88,33 @@ public static function get_metadata_field_definition() {
8888

8989
// Check "key" argument and format meta_data objects.
9090
if ( ! empty( $args['key'] ) && $source->meta_exists( $args['key'] ) ) {
91-
$data = $source->get_meta( $args['key'], $single );
92-
if ( ! is_array( $data ) ) {
93-
$data = array_filter(
94-
$source->get_meta_data(),
95-
static function ( $meta ) use ( $data ) {
96-
return $meta->value === $data;
97-
}
98-
);
91+
$key = $args['key'];
92+
$data = $source->get_meta( $key, false );
93+
if ( empty( $data ) ) {
94+
$data = [];
95+
} elseif ( $single ) {
96+
$data = array_slice( $data, 0, 1 );
9997
}
98+
99+
$data = array_map(
100+
static function ( $value ) {
101+
return (object) $value;
102+
},
103+
$data
104+
);
100105
} elseif ( ! empty( $args['keysIn'] ) ) {
101106
// Check "keysIn" argument and format meta_data objects.
102-
$keys = $args['keysIn'];
107+
$keys_in = $args['keysIn'];
103108

104109
$found = [];
105110
$data = array_filter(
106111
$source->get_meta_data(),
107-
static function ( $meta ) use ( $keys, $single, &$found ) {
108-
if ( in_array( $meta->key, $keys, true ) ) {
109-
if ( $single ) {
110-
if ( ! in_array( $meta->key, $found, true ) ) {
111-
$found[] = $meta->key;
112-
return true;
113-
}
112+
static function ( $meta ) use ( $keys_in, $single, &$found ) {
113+
if ( in_array( $meta->key, $keys_in, true ) ) {
114+
if ( $single && in_array( $meta->key, $found, true ) ) {
114115
return false;
115116
}
117+
$found[] = $meta->key;
116118
return true;
117119
}
118120
}
@@ -123,13 +125,11 @@ static function ( $meta ) use ( $keys, $single, &$found ) {
123125
$data = array_filter(
124126
$source->get_meta_data(),
125127
static function ( $meta ) use ( $single, &$found ) {
126-
if ( $single ) {
127-
if ( ! in_array( $meta->key, $found, true ) ) {
128-
$found[] = $meta->key;
129-
return true;
130-
}
128+
if ( $single && in_array( $meta->key, $found, true ) ) {
131129
return false;
132130
}
131+
132+
$found[] = $meta->key;
133133
return true;
134134
}
135135
);

vendor-prefixed/firebase/php-jwt/src/CachedKeySet.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ public function __construct(
8686
ClientInterface $httpClient,
8787
RequestFactoryInterface $httpFactory,
8888
CacheItemPoolInterface $cache,
89-
int $expiresAfter = null,
89+
?int $expiresAfter = null,
9090
bool $rateLimit = false,
91-
string $defaultAlg = null
91+
?string $defaultAlg = null
9292
) {
9393
$this->jwksUri = $jwksUri;
9494
$this->httpClient = $httpClient;
@@ -186,7 +186,7 @@ private function keyIdExists(string $keyId): bool
186186
$jwksResponse = $this->httpClient->sendRequest($request);
187187
if ($jwksResponse->getStatusCode() !== 200) {
188188
throw new UnexpectedValueException(
189-
sprintf('HTTP Error: %d %s for URI "%s"',
189+
\sprintf('HTTP Error: %d %s for URI "%s"',
190190
$jwksResponse->getStatusCode(),
191191
$jwksResponse->getReasonPhrase(),
192192
$this->jwksUri,

0 commit comments

Comments
 (0)