Skip to content

Commit 887eeea

Browse files
authored
Merge pull request #2535 from nextcloud/dependabot/composer/aws/aws-sdk-php-3.389.0
build(deps): bump aws/aws-sdk-php from 3.376.2 to 3.391.1
2 parents 73c0b90 + 0cb30e2 commit 887eeea

84 files changed

Lines changed: 3144 additions & 622 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

aws/aws-sdk-php/src/Api/Serializer/AbstractRpcV2Serializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __invoke(
7878
// Content-Type must not be set
7979
if ($operation['input'] !== null) {
8080
$body = $this->serialize($operation->getInput(), $commandArgs);
81-
$headers['Content-Length'] = strlen($body);
81+
$headers['Content-Length'] = (string) strlen($body);
8282
} else {
8383
unset($headers['Content-Type']);
8484
}

aws/aws-sdk-php/src/Api/Serializer/JsonRpcSerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __invoke(
6666
$headers = [
6767
'X-Amz-Target' => $this->api->getMetadata('targetPrefix') . '.' . $operationName,
6868
'Content-Type' => $this->contentType,
69-
'Content-Length' => strlen($body)
69+
'Content-Length' => (string) strlen($body)
7070
];
7171

7272
if ($endpoint instanceof RulesetEndpoint) {

aws/aws-sdk-php/src/Api/Serializer/QuerySerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __invoke(
6161
}
6262
$body = http_build_query($body, '', '&', PHP_QUERY_RFC3986);
6363
$headers = [
64-
'Content-Length' => strlen($body),
64+
'Content-Length' => (string) strlen($body),
6565
'Content-Type' => 'application/x-www-form-urlencoded'
6666
];
6767
$requestUri = $operation['http']['requestUri'] ?? null;

aws/aws-sdk-php/src/Api/Serializer/RestJsonSerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function payload(StructureShape $member, array|string $value, array &$
3535
{
3636
$opts['headers']['Content-Type'] = $this->contentType;
3737
$body = $this->jsonFormatter->build($member, $value);
38-
$opts['headers']['Content-Length'] = strlen($body);
38+
$opts['headers']['Content-Length'] = (string) strlen($body);
3939
$opts['body'] = $body;
4040
}
4141
}

aws/aws-sdk-php/src/Api/Serializer/RestSerializer.php

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,18 @@ private function applyPayload(StructureShape $input, $name, array $args, array &
159159

160160
$body = $args[$name];
161161
if (!$m['streaming'] && is_string($body)) {
162-
$opts['headers']['Content-Length'] = strlen($body);
162+
$opts['headers']['Content-Length'] = (string) strlen($body);
163163
}
164164

165165
// Streaming bodies or payloads that are strings are
166166
// always just a stream of data.
167-
$opts['body'] = Psr7\Utils::streamFor($body);
167+
$stream = Psr7\Utils::streamFor($body);
168+
// User-owned resource which should be detached instead of closed
169+
// during garbage-collection
170+
if (is_resource($body)) {
171+
$stream = \Aws\detach_on_close_stream($stream);
172+
}
173+
$opts['body'] = $stream;
168174
return;
169175
}
170176

@@ -173,20 +179,36 @@ private function applyPayload(StructureShape $input, $name, array $args, array &
173179

174180
private function applyHeader($name, Shape $member, $value, array &$opts)
175181
{
176-
// Handle lists by recursively applying header logic to each element
182+
if ($value === null) {
183+
return;
184+
}
185+
186+
// Handle lists by applying header logic to each element
177187
if ($member instanceof ListShape) {
188+
if (!is_array($value)) {
189+
throw new \InvalidArgumentException('Header values must be scalar or an array of scalars.');
190+
}
191+
178192
$listMember = $member->getMember();
179193
$headerValues = [];
180194

181195
foreach ($value as $listValue) {
196+
if ($listValue === null) {
197+
throw new \InvalidArgumentException('Header values must be scalar or an array of scalars.');
198+
}
199+
182200
$tempOpts = ['headers' => []];
183201
$this->applyHeader('temp', $listMember, $listValue, $tempOpts);
202+
if (!array_key_exists('temp', $tempOpts['headers'])) {
203+
throw new \InvalidArgumentException('Header values must be scalar or an array of scalars.');
204+
}
205+
184206
$convertedValue = $tempOpts['headers']['temp'];
185207
$headerValues[] = $convertedValue;
186208
}
187209

188210
$value = $headerValues;
189-
} elseif (!is_null($value)) {
211+
} else {
190212
switch ($member->getType()) {
191213
case 'timestamp':
192214
$timestampFormat = $member['timestampFormat'] ?? 'rfc822';
@@ -208,7 +230,7 @@ private function applyHeader($name, Shape $member, $value, array &$opts)
208230
$value = base64_encode($value);
209231
}
210232

211-
$opts['headers'][$member['locationName'] ?: $name] = $value;
233+
$opts['headers'][$member['locationName'] ?: $name] = self::prepareHeaderValue($value);
212234
}
213235

214236
/**
@@ -218,8 +240,40 @@ private function applyHeaderMap($name, Shape $member, array $value, array &$opts
218240
{
219241
$prefix = $member['locationName'];
220242
foreach ($value as $k => $v) {
221-
$opts['headers'][$prefix . $k] = $v;
243+
if ($v === null) {
244+
continue;
245+
}
246+
247+
$opts['headers'][$prefix . $k] = self::prepareHeaderValue($v);
248+
}
249+
}
250+
251+
/**
252+
* @return string|string[]
253+
*/
254+
private static function prepareHeaderValue($value)
255+
{
256+
if (is_scalar($value)) {
257+
return (string) $value;
258+
}
259+
260+
if (is_array($value)) {
261+
if ($value === []) {
262+
return '';
263+
}
264+
265+
foreach ($value as $key => $item) {
266+
if (!is_scalar($item)) {
267+
throw new \InvalidArgumentException('Header values must be scalar or an array of scalars.');
268+
}
269+
270+
$value[$key] = (string) $item;
271+
}
272+
273+
return $value;
222274
}
275+
276+
throw new \InvalidArgumentException('Header values must be scalar or an array of scalars.');
223277
}
224278

225279
private function applyQuery($name, Shape $member, $value, array &$opts)

aws/aws-sdk-php/src/Api/Serializer/RestXmlSerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function payload(StructureShape $member, array $value, array &$opts)
3030
{
3131
$opts['headers']['Content-Type'] = 'application/xml';
3232
$body = $this->getXmlBody($member, $value);
33-
$opts['headers']['Content-Length'] = strlen($body);
33+
$opts['headers']['Content-Length'] = (string) strlen($body);
3434
$opts['body'] = $body;
3535
}
3636

aws/aws-sdk-php/src/AwsClient.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ private function addQueryModeHeader(): void
544544
{
545545
$list = $this->getHandlerList();
546546
$list->appendBuild(
547-
Middleware::mapRequest(function (RequestInterface $r) {
547+
Middleware::mapRequest(static function (RequestInterface $r) {
548548
return $r->withHeader(
549549
'x-amzn-query-mode',
550550
"true"
@@ -657,11 +657,12 @@ private function addUserAgentMiddleware($args)
657657
*/
658658
private function addEventStreamHttpFlagMiddleware(): void
659659
{
660+
$api = $this->getApi();
660661
$this->getHandlerList()
661662
-> appendInit(
662-
function (callable $handler) {
663-
return function (CommandInterface $command, $request = null) use ($handler) {
664-
$operation = $this->getApi()->getOperation($command->getName());
663+
static function (callable $handler) use ($api) {
664+
return static function (CommandInterface $command, $request = null) use ($handler, $api) {
665+
$operation = $api->getOperation($command->getName());
665666
$output = $operation->getOutput();
666667
foreach ($output->getMembers() as $memberProps) {
667668
if (!empty($memberProps['eventstream'])) {

aws/aws-sdk-php/src/ClientResolver.php

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@
2727
use Aws\EndpointDiscovery\ConfigurationInterface;
2828
use Aws\EndpointDiscovery\ConfigurationProvider;
2929
use Aws\EndpointV2\EndpointDefinitionProvider;
30+
use Aws\EndpointV2\EndpointProviderV2;
3031
use Aws\Exception\AwsException;
3132
use Aws\Exception\InvalidRegionException;
3233
use Aws\Retry\ConfigurationInterface as RetryConfigInterface;
3334
use Aws\Retry\ConfigurationProvider as RetryConfigProvider;
35+
use Aws\Retry\V3\OptIn as NewRetriesOptIn;
36+
use Aws\Retry\V3\RetryMiddleware as RetryV3Middleware;
3437
use Aws\Signature\SignatureProvider;
3538
use Aws\Token\Token;
3639
use Aws\Token\TokenInterface;
@@ -547,28 +550,42 @@ private function throwRequired(array $args)
547550
public static function _apply_retries($value, array &$args, HandlerList $list)
548551
{
549552
// A value of 0 for the config option disables retries
550-
if ($value) {
551-
$config = RetryConfigProvider::unwrap($value);
553+
if (!$value) {
554+
return;
555+
}
552556

553-
if ($config->getMode() === 'legacy') {
554-
// # of retries is 1 less than # of attempts
555-
$decider = RetryMiddleware::createDefaultDecider(
556-
$config->getMaxAttempts() - 1
557-
);
558-
$list->appendSign(
559-
Middleware::retry($decider, null, $args['stats']['retries']),
560-
'retry'
561-
);
562-
} else {
563-
$list->appendSign(
564-
RetryMiddlewareV2::wrap(
565-
$config,
566-
['collect_stats' => $args['stats']['retries']]
567-
),
568-
'retry'
569-
);
570-
}
557+
$config = RetryConfigProvider::unwrap($value);
558+
559+
if ($config->getMode() === 'legacy') {
560+
// # of retries is 1 less than # of attempts
561+
$decider = RetryMiddleware::createDefaultDecider(
562+
$config->getMaxAttempts() - 1
563+
);
564+
$list->appendSign(
565+
Middleware::retry($decider, null, $args['stats']['retries']),
566+
'retry'
567+
);
568+
return;
569+
}
570+
571+
if (NewRetriesOptIn::isEnabled()) {
572+
$list->appendSign(
573+
RetryV3Middleware::wrap($config, [
574+
'collect_stats' => $args['stats']['retries'],
575+
'service' => $args['service'],
576+
]),
577+
'retry'
578+
);
579+
return;
571580
}
581+
582+
$list->appendSign(
583+
RetryMiddlewareV2::wrap(
584+
$config,
585+
['collect_stats' => $args['stats']['retries']]
586+
),
587+
'retry'
588+
);
572589
}
573590

574591
public static function _apply_defaults($value, array &$args, HandlerList $list)
@@ -791,7 +808,7 @@ public static function _apply_api_provider(callable $value, array &$args)
791808
public static function _apply_endpoint_provider($value, array &$args)
792809
{
793810
if (!isset($args['endpoint'])) {
794-
if ($value instanceof \Aws\EndpointV2\EndpointProviderV2) {
811+
if ($value instanceof EndpointProviderV2) {
795812
$options = self::getEndpointProviderOptions($args);
796813
$value = PartitionEndpointProvider::defaultProvider($options)
797814
->getPartition($args['region'], $args['service']);
@@ -1112,14 +1129,13 @@ public static function _default_endpoint_provider(array $args)
11121129
if (self::isValidService($serviceName)
11131130
&& self::isValidApiVersion($serviceName, $apiVersion)
11141131
) {
1115-
$ruleset = EndpointDefinitionProvider::getEndpointRuleset(
1132+
$partitions = EndpointDefinitionProvider::getPartitions();
1133+
$parsed = EndpointDefinitionProvider::getParsedRuleset(
11161134
$service->getServiceName(),
1117-
$service->getApiVersion()
1118-
);
1119-
return new \Aws\EndpointV2\EndpointProviderV2(
1120-
$ruleset,
1121-
EndpointDefinitionProvider::getPartitions()
1135+
$service->getApiVersion(),
1136+
$partitions
11221137
);
1138+
return new EndpointProviderV2($parsed, $partitions);
11231139
}
11241140
$options = self::getEndpointProviderOptions($args);
11251141
return PartitionEndpointProvider::defaultProvider($options)

0 commit comments

Comments
 (0)