Skip to content
Commits on Source (13)
......@@ -28,6 +28,7 @@ RUN apt-get update && apt-get install -y \
php7.3-zip \
php7.3-gmp \
php7.3-xdebug \
php7.3-gd \
php7.3-mbstring \
&& rm -rf /var/lib/apt/lists/*
COPY ./php-ini-overrides.ini /etc/php/7.3/cli/conf.d/
......@@ -42,13 +43,12 @@ RUN apt-get update && apt-get install -y \
php7.4-zip \
php7.4-gmp \
php7.4-xdebug \
php7.4-gd \
php7.4-mbstring \
&& rm -rf /var/lib/apt/lists/*
COPY ./php-ini-overrides.ini /etc/php/7.4/cli/conf.d/
# PHP 8.0
# FIXME: php8.0-xdebug not installed because it leads to segfaults
# https://gitlab.tugraz.at/dbp/middleware/api/-/issues/65#note_21039
RUN apt-get update && apt-get install -y \
php8.0 \
php8.0-curl \
......@@ -57,6 +57,8 @@ RUN apt-get update && apt-get install -y \
php8.0-ldap \
php8.0-zip \
php8.0-gmp \
php8.0-xdebug \
php8.0-gd \
php8.0-mbstring \
&& rm -rf /var/lib/apt/lists/*
COPY ./php-ini-overrides.ini /etc/php/8.0/cli/conf.d/
......
......@@ -167,16 +167,16 @@
},
{
"name": "doctrine/annotations",
"version": "1.13.1",
"version": "1.13.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "e6e7b7d5b45a2f2abc5460cc6396480b2b1d321f"
"reference": "5b668aef16090008790395c02c893b1ba13f7e08"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/e6e7b7d5b45a2f2abc5460cc6396480b2b1d321f",
"reference": "e6e7b7d5b45a2f2abc5460cc6396480b2b1d321f",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/5b668aef16090008790395c02c893b1ba13f7e08",
"reference": "5b668aef16090008790395c02c893b1ba13f7e08",
"shasum": ""
},
"require": {
......@@ -233,9 +233,9 @@
],
"support": {
"issues": "https://github.com/doctrine/annotations/issues",
"source": "https://github.com/doctrine/annotations/tree/1.13.1"
"source": "https://github.com/doctrine/annotations/tree/1.13.2"
},
"time": "2021-05-16T18:07:53+00:00"
"time": "2021-08-05T19:00:23+00:00"
},
{
"name": "doctrine/inflector",
......@@ -5719,16 +5719,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.0.0",
"version": "v3.0.2",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "c15377bdfa8d1ecf186f1deadec39c89984e1167"
"reference": "990b979379502feb7f393d6c9aa36cc9b9765f24"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c15377bdfa8d1ecf186f1deadec39c89984e1167",
"reference": "c15377bdfa8d1ecf186f1deadec39c89984e1167",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/990b979379502feb7f393d6c9aa36cc9b9765f24",
"reference": "990b979379502feb7f393d6c9aa36cc9b9765f24",
"shasum": ""
},
"require": {
......@@ -5795,7 +5795,7 @@
"description": "A tool to automatically fix PHP code style",
"support": {
"issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues",
"source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v3.0.0"
"source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v3.0.2"
},
"funding": [
{
......@@ -5803,7 +5803,7 @@
"type": "github"
}
],
"time": "2021-05-03T21:51:58+00:00"
"time": "2021-08-04T19:28:19+00:00"
},
{
"name": "netresearch/jsonmapper",
......@@ -6019,16 +6019,16 @@
},
{
"name": "phpstan/phpstan",
"version": "0.12.94",
"version": "0.12.96",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "3d0ba4c198a24e3c3fc489f3ec6ac9612c4be5d6"
"reference": "a98bdc51318f20fcae8c953d266f81a70254917f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/3d0ba4c198a24e3c3fc489f3ec6ac9612c4be5d6",
"reference": "3d0ba4c198a24e3c3fc489f3ec6ac9612c4be5d6",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/a98bdc51318f20fcae8c953d266f81a70254917f",
"reference": "a98bdc51318f20fcae8c953d266f81a70254917f",
"shasum": ""
},
"require": {
......@@ -6059,7 +6059,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/0.12.94"
"source": "https://github.com/phpstan/phpstan/tree/0.12.96"
},
"funding": [
{
......@@ -6079,25 +6079,25 @@
"type": "tidelift"
}
],
"time": "2021-07-30T09:05:27+00:00"
"time": "2021-08-21T11:55:13+00:00"
},
{
"name": "phpstan/phpstan-phpunit",
"version": "0.12.21",
"version": "0.12.22",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "6aaff1196c4f808769774b49a94a60e5fdf18de7"
"reference": "7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6aaff1196c4f808769774b49a94a60e5fdf18de7",
"reference": "6aaff1196c4f808769774b49a94a60e5fdf18de7",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc",
"reference": "7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0",
"phpstan/phpstan": "^0.12.86"
"phpstan/phpstan": "^0.12.92"
},
"conflict": {
"phpunit/phpunit": "<7.0"
......@@ -6131,9 +6131,9 @@
"description": "PHPUnit extensions and rules for PHPStan",
"support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.21"
"source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.22"
},
"time": "2021-07-14T10:48:30+00:00"
"time": "2021-08-12T10:53:43+00:00"
},
{
"name": "sebastian/diff",
......@@ -6888,16 +6888,16 @@
},
{
"name": "vimeo/psalm",
"version": "4.9.2",
"version": "4.9.3",
"source": {
"type": "git",
"url": "https://github.com/vimeo/psalm.git",
"reference": "00c062267d6e3229d91a1939992987e2d46f2393"
"reference": "4c262932602b9bbab5020863d1eb22d49de0dbf4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/00c062267d6e3229d91a1939992987e2d46f2393",
"reference": "00c062267d6e3229d91a1939992987e2d46f2393",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/4c262932602b9bbab5020863d1eb22d49de0dbf4",
"reference": "4c262932602b9bbab5020863d1eb22d49de0dbf4",
"shasum": ""
},
"require": {
......@@ -6939,7 +6939,6 @@
"slevomat/coding-standard": "^7.0",
"squizlabs/php_codesniffer": "^3.5",
"symfony/process": "^4.3 || ^5.0",
"weirdan/phpunit-appveyor-reporter": "^1.0.0",
"weirdan/prophecy-shim": "^1.0 || ^2.0"
},
"suggest": {
......@@ -6987,9 +6986,9 @@
],
"support": {
"issues": "https://github.com/vimeo/psalm/issues",
"source": "https://github.com/vimeo/psalm/tree/4.9.2"
"source": "https://github.com/vimeo/psalm/tree/4.9.3"
},
"time": "2021-08-01T01:15:26+00:00"
"time": "2021-08-14T16:19:38+00:00"
},
{
"name": "webmozart/path-util",
......
......@@ -13,4 +13,50 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
*/
class ApiError extends HttpException
{
/**
* @var ?string
*/
private $errorId;
/**
* @var ?array
*/
private $errorDetails;
public function __construct(int $statusCode, ?string $message = '', \Throwable $previous = null, array $headers = [], ?int $code = 0)
{
$message = json_decode($message, true);
if ($message === null) {
$message = [
'message' => $message,
'errorId' => '',
'errorDetails' => null,
];
}
parent::__construct($statusCode, json_encode($message), $previous, $headers, $code);
}
public function setErrorDetails(string $errorId, array $errorDetails = [])
{
$this->errorId = $errorId;
$this->errorDetails = $errorDetails;
}
public function getErrorDetails(): array
{
return [$this->errorId, $this->errorDetails];
}
public static function withDetails(int $statusCode, ?string $message = '', string $errorId = '', array $errorDetails = [])
{
$message = [
'message' => $message,
'errorId' => $errorId,
'errorDetails' => $errorDetails,
];
return new ApiError($statusCode, json_encode($message));
}
}
......@@ -24,24 +24,39 @@ class ApiErrorNormalizer implements ContextAwareNormalizerInterface, NormalizerA
private const ALREADY_CALLED = 'ALREADY_CALLED_'.ApiErrorNormalizer::class;
private const SUPPORTED_CLASS = APIError::class;
public function normalize($object, $format = null, array $context = [])
{
$context[self::ALREADY_CALLED] = true;
$normalized = $this->normalizer->normalize($object, $format, $context);
if ($object->getClass() === self::SUPPORTED_CLASS) {
if ($object->getClass() === APIError::class) {
$message = $object->getMessage();
$message = json_decode($message, true);
$errorId = $message['errorId'];
$errorDetails = $message['errorDetails'];
$message = $message['message'];
if ($format === 'jsonld') {
if ($message !== '') {
$normalized['hydra:description'] = $message;
}
if ($errorId !== '') {
$normalized['relay:errorId'] = $errorId;
}
if ($errorDetails !== null) {
$normalized['relay:errorDetails'] = $errorDetails;
}
} elseif ($format === 'jsonproblem') {
if ($message !== '') {
$normalized['detail'] = $message;
}
if ($errorId !== '') {
$normalized['errorId'] = $errorId;
}
if ($errorDetails !== null) {
$normalized['errorDetails'] = $errorDetails;
}
}
}
......