bug #36370 Update Connection.php (infinitely-young)

This PR was squashed before being merged into the 5.1-dev branch.

Discussion
----------

Update Connection.php

Get `region` from `host` to prevent error "Credential should be scoped to a valid region, not '...'" and make it easier to setup DSN

| Q             | A
| ------------- | ---
| Branch?       | master for features / 3.4, 4.4 or 5.0 for bug fixes <!-- see below -->
| Bug fix?      | yes/no
| New feature?  | yes/no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch master.
-->

Commits
-------

af6804828b Update Connection.php
This commit is contained in:
Fabien Potencier 2020-04-08 08:10:19 +02:00
commit 168574db29
1 changed files with 3 additions and 0 deletions

View File

@ -105,6 +105,9 @@ class Connection
$configuration['endpoint'] = sprintf('https://sqs.%s.amazonaws.com', $configuration['region']);
} else {
$configuration['endpoint'] = sprintf('%s://%s%s', ($query['sslmode'] ?? null) === 'disable' ? 'http' : 'https', $parsedUrl['host'], ($parsedUrl['port'] ?? null) ? ':'.$parsedUrl['port'] : '');
if (preg_match(';sqs.(.+).amazonaws.com;', $parsedUrl['host'], $matches)) {
$configuration['region'] = $matches[1];
}
unset($query['sslmode']);
}