Skip to content

fix: "key" argument for MetaData fields fixed #921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bin/_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ install_wordpress() {
composer require --dev --no-interaction -W \
johnpbloch/wordpress:* \
wp-graphql/wp-graphql-jwt-authentication \
axepress/wp-graphql-headless-login \
wpackagist-plugin/woocommerce \
wpackagist-plugin/woocommerce-gateway-stripe \
wpackagist-plugin/wp-graphql \
Expand Down
102 changes: 51 additions & 51 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions includes/type/object/class-meta-data-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,33 @@ public static function get_metadata_field_definition() {

// Check "key" argument and format meta_data objects.
if ( ! empty( $args['key'] ) && $source->meta_exists( $args['key'] ) ) {
$data = $source->get_meta( $args['key'], $single );
if ( ! is_array( $data ) ) {
$data = array_filter(
$source->get_meta_data(),
static function ( $meta ) use ( $data ) {
return $meta->value === $data;
}
);
$key = $args['key'];
$data = $source->get_meta( $key, false );
if ( empty( $data ) ) {
$data = [];
} elseif ( $single ) {
$data = array_slice( $data, 0, 1 );
}

$data = array_map(
static function ( $value ) {
return (object) $value;
},
$data
);
} elseif ( ! empty( $args['keysIn'] ) ) {
// Check "keysIn" argument and format meta_data objects.
$keys = $args['keysIn'];
$keys_in = $args['keysIn'];

$found = [];
$data = array_filter(
$source->get_meta_data(),
static function ( $meta ) use ( $keys, $single, &$found ) {
if ( in_array( $meta->key, $keys, true ) ) {
if ( $single ) {
if ( ! in_array( $meta->key, $found, true ) ) {
$found[] = $meta->key;
return true;
}
static function ( $meta ) use ( $keys_in, $single, &$found ) {
if ( in_array( $meta->key, $keys_in, true ) ) {
if ( $single && in_array( $meta->key, $found, true ) ) {
return false;
}
$found[] = $meta->key;
return true;
}
}
Expand All @@ -123,13 +125,11 @@ static function ( $meta ) use ( $keys, $single, &$found ) {
$data = array_filter(
$source->get_meta_data(),
static function ( $meta ) use ( $single, &$found ) {
if ( $single ) {
if ( ! in_array( $meta->key, $found, true ) ) {
$found[] = $meta->key;
return true;
}
if ( $single && in_array( $meta->key, $found, true ) ) {
return false;
}

$found[] = $meta->key;
return true;
}
);
Expand Down
6 changes: 3 additions & 3 deletions vendor-prefixed/firebase/php-jwt/src/CachedKeySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ public function __construct(
ClientInterface $httpClient,
RequestFactoryInterface $httpFactory,
CacheItemPoolInterface $cache,
int $expiresAfter = null,
?int $expiresAfter = null,
bool $rateLimit = false,
string $defaultAlg = null
?string $defaultAlg = null
) {
$this->jwksUri = $jwksUri;
$this->httpClient = $httpClient;
Expand Down Expand Up @@ -186,7 +186,7 @@ private function keyIdExists(string $keyId): bool
$jwksResponse = $this->httpClient->sendRequest($request);
if ($jwksResponse->getStatusCode() !== 200) {
throw new UnexpectedValueException(
sprintf('HTTP Error: %d %s for URI "%s"',
\sprintf('HTTP Error: %d %s for URI "%s"',
$jwksResponse->getStatusCode(),
$jwksResponse->getReasonPhrase(),
$this->jwksUri,
Expand Down
Loading
Loading