mirror of
https://github.com/shlinkio/shlink.git
synced 2026-02-28 12:13:13 +08:00
Merge pull request #2397 from acelaya-forks/feature/endroid-fix
Fix error intrduced by endroid/qr-code 6.0.4
This commit is contained in:
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
|
||||
|
||||
## [Unreleased]
|
||||
## [4.4.6] - 2025-03-20
|
||||
### Added
|
||||
* *Nothing*
|
||||
|
||||
@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
|
||||
|
||||
### Fixed
|
||||
* [#2391](https://github.com/shlinkio/shlink/issues/2391) When sending visits to Matomo, send the country code, not the country name.
|
||||
* Fix error with new option introduced by `endroid/qr-code` 6.0.4.
|
||||
|
||||
|
||||
## [4.4.5] - 2025-03-01
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
"doctrine/migrations": "^3.8",
|
||||
"doctrine/orm": "^3.3",
|
||||
"donatj/phpuseragentparser": "^1.10",
|
||||
"endroid/qr-code": "<6.0.4",
|
||||
"endroid/qr-code": "^6.0.5",
|
||||
"friendsofphp/proxy-manager-lts": "^1.0",
|
||||
"geoip2/geoip2": "^3.1",
|
||||
"guzzlehttp/guzzle": "^7.9",
|
||||
@@ -77,7 +77,8 @@
|
||||
"veewee/composer-run-parallel": "^1.4"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/var-exporter": ">=6.3.9,<=6.4.0"
|
||||
"symfony/var-exporter": ">=6.3.9,<=6.4.0",
|
||||
"phpunit/phpunit": "12.0.9"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -38,6 +38,7 @@ final readonly class QrCodeParams
|
||||
public int $size,
|
||||
public int $margin,
|
||||
public WriterInterface $writer,
|
||||
public array $writerOptions,
|
||||
public ErrorCorrectionLevel $errorCorrectionLevel,
|
||||
public RoundBlockSizeMode $roundBlockSizeMode,
|
||||
public ColorInterface $color,
|
||||
@@ -49,11 +50,13 @@ final readonly class QrCodeParams
|
||||
public static function fromRequest(ServerRequestInterface $request, QrCodeOptions $defaults): self
|
||||
{
|
||||
$query = $request->getQueryParams();
|
||||
[$writer, $writerOptions] = self::resolveWriterAndWriterOptions($query, $defaults);
|
||||
|
||||
return new self(
|
||||
size: self::resolveSize($query, $defaults),
|
||||
margin: self::resolveMargin($query, $defaults),
|
||||
writer: self::resolveWriter($query, $defaults),
|
||||
writer: $writer,
|
||||
writerOptions: $writerOptions,
|
||||
errorCorrectionLevel: self::resolveErrorCorrection($query, $defaults),
|
||||
roundBlockSizeMode: self::resolveRoundBlockSize($query, $defaults),
|
||||
color: self::resolveColor($query, $defaults),
|
||||
@@ -83,14 +86,17 @@ final readonly class QrCodeParams
|
||||
return max($intMargin, 0);
|
||||
}
|
||||
|
||||
private static function resolveWriter(array $query, QrCodeOptions $defaults): WriterInterface
|
||||
/**
|
||||
* @return array{WriterInterface, array}
|
||||
*/
|
||||
private static function resolveWriterAndWriterOptions(array $query, QrCodeOptions $defaults): array
|
||||
{
|
||||
$qFormat = self::normalizeParam($query['format'] ?? '');
|
||||
$format = contains($qFormat, self::SUPPORTED_FORMATS) ? $qFormat : self::normalizeParam($defaults->format);
|
||||
|
||||
return match ($format) {
|
||||
'svg' => new SvgWriter(),
|
||||
default => new PngWriter(),
|
||||
'svg' => [new SvgWriter(), []],
|
||||
default => [new PngWriter(), [PngWriter::WRITER_OPTION_NUMBER_OF_COLORS => null]],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ readonly class QrCodeAction implements MiddlewareInterface
|
||||
$params = QrCodeParams::fromRequest($request, $this->options);
|
||||
$qrCodeBuilder = new Builder(
|
||||
writer: $params->writer,
|
||||
writerOptions: $params->writerOptions,
|
||||
data: $this->stringifier->stringify($shortUrl),
|
||||
errorCorrectionLevel: $params->errorCorrectionLevel,
|
||||
size: $params->size,
|
||||
|
||||
Reference in New Issue
Block a user